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
$ ansible-parallel *.yml
# 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
Hashes for ansible-parallel-2021.1.20.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a2ec4c6e7250651d23614bd61c4c6f7c9227216fe44ac1c17fecfcab46517ab |
|
MD5 | 7ddf5c0c95d917c350758e81ef6fe5af |
|
BLAKE2b-256 | cb3c059ff822b540e45a14a0233fd28cc9ad6fdfee7fda08286ba2d3de4b3c08 |
Hashes for ansible_parallel-2021.1.20-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 095bf3b447df491ef1a4ea331338ae0bccf4e9b94a67cf3530b5a528d01c21a7 |
|
MD5 | 27aa1b7a0b730d310df8b95c208e6aac |
|
BLAKE2b-256 | b1c4ed39b8462c2f6eabedccf5117205cfd2e60e794cddb48965b60bee404b75 |