Created
September 5, 2018 17:06
-
-
Save xlbruce/d71bf67a211bd096f98def01837b439c to your computer and use it in GitHub Desktop.
Run arbitrary async commands
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
--- | |
- name: Run async tasks | |
hosts: localhost | |
connection: local | |
gather_facts: no | |
tasks: | |
- name: Sleep 2 times | |
shell: /bin/sleep 5 | |
async: 10000 | |
poll: 0 | |
with_items: [1, 2] | |
register: sleep | |
- debug: var=sleep | |
- name: Wait tasks to finish | |
async_status: jid={{ item.ansible_job_id }} | |
with_items: "{{ sleep.results }}" | |
register: jobs | |
until: jobs.finished | |
retries: 5 | |
- debug: var=jobs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment