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?

1
  • 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, 2019 at 11:40

2 Answers 2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .