Run ansible playbooks in parallel.
Project description
ansible-parallel
TL;DR:
pip install ansible-parallel
ansible-parallel *.yml
Executes multiple ansible playbooks in parallel.
For my usage, running sequentially (using a site.yml
containing
multiple import_playbook
) takes 30mn, running in parallel takes
10mn.
Usage
ansible-parallel
runs like ansible-playbook
but accepts multiple
playbooks. All remaining options are passed to ansible-playbook
so
feel free to run ansible-parallel --check *.yml
for example.
Example
It's easy to start:
$ ansible-parallel *.yml
When it runs, it display a live update of what's going on, one line per playbook:
web.yml: TASK [common : Configure Debian repositories] *****************************
gitlab.yml: TASK [common : Configure IP failover] *************************************
staging.yml: TASK [common : Configure Debian repositories] *****************************
dev.yml: Done.
And when it's done, it prints a full report like:
# Playbook playbook-webs.yml, ran in 123s
web1.meltygroup.com : ok=51 changed=0 unreachable=0 failed=0 skipped=12 rescued=0 ignored=0
web2.meltygroup.com : ok=51 changed=0 unreachable=0 failed=0 skipped=12 rescued=0 ignored=0
web3.meltygroup.com : ok=51 changed=0 unreachable=0 failed=0 skipped=12 rescued=0 ignored=0
# Playbook playbook-staging.yml, ran in 138s
staging1.meltygroup.com : ok=64 changed=6 unreachable=0 failed=0 skipped=18 rescued=0 ignored=0
# Playbook playbook-gitlab.yml, ran in 179s
gitlab-runner1.meltygroup.com : ok=47 changed=0 unreachable=0 failed=0 skipped=13 rescued=0 ignored=0
gitlab-runner2.meltygroup.com : ok=47 changed=0 unreachable=0 failed=0 skipped=13 rescued=0 ignored=0
gitlab-runner3.meltygroup.com : ok=47 changed=0 unreachable=0 failed=0 skipped=13 rescued=0 ignored=0
gitlab.meltygroup.com : ok=51 changed=0 unreachable=0 failed=0 skipped=12 rescued=0 ignored=0
# Playbook playbook-devs.yml, ran in 213s
dev1.meltygroup.com : ok=121 changed=0 unreachable=0 failed=0 skipped=22 rescued=0 ignored=0
dev2.meltygroup.com : ok=121 changed=0 unreachable=0 failed=0 skipped=22 rescued=0 ignored=0
Known alternatives
ansible-pull
ansible-parallel is only good if you want to keep the push behavior of Ansible, but if you're here you may have a lot of playbooks, and switching to ansible-pull with a proper reporting system like ARA
xargs
A quick and dirty way of doing it in 3 lines of bash:
ls -1 *.yml | xargs -n1 -P16 sh -c 'ansible-playbook "$$0" > "$$0.log"' ||:
grep -B1 "^\(changed\|fatal\|failed\):" *.log
echo *.yml.log | xargs -n1 sed -n -e '/^PLAY RECAP/,$$p'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ansible-parallel-2023.3.13.tar.gz
.
File metadata
- Download URL: ansible-parallel-2023.3.13.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62b1b332a2c3e4fb4e84c19f5ae6d5b2d7691c033d520c379cebd652af21ff93 |
|
MD5 | 89f4fa90f3468ad7e533111ad0e255dc |
|
BLAKE2b-256 | a2c6557cf9888c38328889e05d0c0c17e1682bdbec97f7e64fa3f0e61990f9bb |
File details
Details for the file ansible_parallel-2023.3.13-py3-none-any.whl
.
File metadata
- Download URL: ansible_parallel-2023.3.13-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6453e2b8e5951c05d66f163aad3027f91d7b9a4da7db0eb9d065bcd3a2e9f71a |
|
MD5 | c5ca6dc659b9c3da4a6d71627ab7ad2c |
|
BLAKE2b-256 | 5bd5dbc1a07e2ceaef05e565a0ba89630fc5c5bffad8d6d8dedd98dc70ef8b2a |