Created
July 12, 2018 10:11
-
-
Save versionsix/833eadc91b5e578add3da7f9e5e16c64 to your computer and use it in GitHub Desktop.
Ansible async task snippet
This file contains 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
--- | |
- 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 😁" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment