Created
January 23, 2019 00:01
-
-
Save guoqiao/28b18253a1abdb902858e2d733ca90c3 to your computer and use it in GitHub Desktop.
Ansible task loop in parallel with async mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ansible-playbook | |
--- | |
- hosts: localhost | |
gather_facts: no | |
tasks: | |
- name: sleep 10s | |
command: "sleep 10" | |
loop: "{{range(3)|list}}" | |
async: 11 | |
poll: 0 | |
register: async_loop | |
- debug: var=async_loop | |
- name: wait | |
async_status: | |
jid: "{{item.ansible_job_id}}" | |
mode: status | |
retries: 11 | |
delay: 1 | |
loop: "{{async_loop.results}}" | |
register: async_loop_jobs | |
until: async_loop_jobs.finished | |
- debug: var=async_loop_jobs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment