Ansible async task snippet
---
- hosts: localhost
connection: local
tasks:
- name: simulate long running op, allow to run for 16 sec, fire and forget
command: "/bin/sleep {{ item }}"
async: 16
register: my_async_job
poll: 0
loop: [1, 3, 15, 4]
- name: 'SLEEP - check on async task'
async_status: jid="{{ item.ansible_job_id }}"
register: job_result
loop: "{{ my_async_job.results }}"
until: job_result.finished
retries: 30
loop_control:
label: "Current task: {{ item.item }}" # add custom message
- debug:
msg: "Play ended 😁"