Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ansible-parallel-2021.1.4.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ansible_parallel-2021.1.4-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file ansible-parallel-2021.1.4.tar.gz.

File metadata

  • Download URL: ansible-parallel-2021.1.4.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.0

File hashes

Hashes for ansible-parallel-2021.1.4.tar.gz
Algorithm Hash digest
SHA256 7f827712359189d62253eb899d4e466ea1f737ab8dc50d6d18559fc8dce38fd8
MD5 bc08797f3c610c2479984c357a1d2947
BLAKE2b-256 dc95b7b89cb55865707d42d103fddcfd8c85b2f0e70a43470b8184b06d52dee7

See more details on using hashes here.

File details

Details for the file ansible_parallel-2021.1.4-py3-none-any.whl.

File metadata

  • Download URL: ansible_parallel-2021.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.0

File hashes

Hashes for ansible_parallel-2021.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 102a54c78bd9554c54096ab11f14e3158d0901fe3ca47317656bf6b5f7cbb7a6
MD5 379c8f366390365f903db7daa06f563c
BLAKE2b-256 22032ef0f3268a500b7fd14f23303e290937a9de400882a3de0b811cc8243616

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page