Skip to content

Instantly share code, notes, and snippets.

@xlbruce
Created September 5, 2018 17:06
Show Gist options
  • Save xlbruce/d71bf67a211bd096f98def01837b439c to your computer and use it in GitHub Desktop.
Save xlbruce/d71bf67a211bd096f98def01837b439c to your computer and use it in GitHub Desktop.
Run arbitrary async commands
---
- 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