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'
Metadata
Release files for ansible-parallel 2023.7.26
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ansible-parallel-2023.7.26.tar.gz | 5.1 kB | Without provenance | Details for ansible-parallel-2023.7.26.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ansible_parallel-2023.7.26-py3-none-any.whl | Python 3 | none | any | Details for ansible_parallel-2023.7.26-py3-none-any.whl |
Total release size: 10.6 kB
Release files / ansible-parallel-2023.7.26.tar.gz
| Download URL | ansible-parallel-2023.7.26.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9eb6c201d7163afdfb886f6c2c69bf01bdfbbc6c463bae748a1c59bc4590c84f
|
|
BLAKE2b-256 checksum How to use checksums |
9281f75b88072fe2f390b5e192489f10e8b28fcb72159bd0ceaf7fc6fd999db4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / ansible_parallel-2023.7.26-py3-none-any.whl
| Download URL | ansible_parallel-2023.7.26-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
17c11398285d0711880d0ac8584ee16b25d2e80a5274b6aafa7facf99ae5853b
|
|
BLAKE2b-256 checksum How to use checksums |
b57d9fee73985c343b60bc89c0af2f75f7aa8890e330a85c0295abb2f588fe7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for ansible-parallel 2023.7.26
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.