3

site.yml

---
- import_playbook: common.yml
- import_playbook: redis.yml
- import_playbook: riak.yml
- import_playbook: webserver.yml
- import_playbook: haproxy.yml

I want to run these playbooks in parallel.
like

- import_playbook: common.yml
# after common.yml run these 4 in parallel
parallel {
- import_playbook: redis.yml
- import_playbook: riak.yml
- import_playbook: webserver.yml
- import_playbook: haproxy.yml
}

How can I do this?

Akhil
  • 1,290
  • i am not aware of an easy way, and it probably will not work on debian/ubuntu because apt will fail if you run multiple apt-get install commands at the same time – sourcejedi Apr 13 '19 at 11:40

2 Answers2

2

An option would be to run the other playbooks in the background

> cat project.bash
#!/bin/bash
ansible-playbook common.yml
# Run the other playbooks in the background
ansible-playbook redis.yml > ansible-redis.log &
ansible-playbook riak.yml > ansible-riak.log &
ansible-playbook webserver.yml > ansible-webster.log &
ansible-playbook haproxy.yml > ansible-haproxy.log &

To monitor the project open four other terminals and watch the log with "tail -f ansible- ..."

1

I'm the author of ansible-parallel, so you can try:

pip install ansible-parallel
ansible-parallel *.yml

It displays a live update of the progression, and a report at the end.