I want to start a long running task in my playbook and immediately move to the next task, and handle the async task return code later. Here is what i have:
---
- hosts: all
tasks:
- name: Invoke jmeter test cases
shell: sleep 10 | echo done
register: out
async: 1000
poll: 1
- name: wait 5 seconds
shell: sleep 5
- debug: var=out
Since i have a non-zero poll value, it waits on the first task to complete entirely and then move to the next one.
TASK [debug] *******************************************************************
ok: [jmeter] => {
"out": {
"ansible_job_id": "844960465574.3266",
"changed": true,
"cmd": "sleep 10 | echo done",
"delta": "0:00:10.006777",
"end": "2017-06-20 08:20:00.965567",
"finished": 1,
"rc": 0,
"start": "2017-06-20 08:19:50.958790",
"stderr": "",
"stdout": "done",
"stdout_lines": [
"done"
],
"warnings": []
}
}
But if i put some non zero value to poll, it fires and forget and even if the task was completed while printing in the debug statement, it gets "finished": 0
TASK [debug] *******************************************************************
ok: [jmeter] => {
"out": {
"ansible_job_id": "229361279978.5796",
"changed": false,
"finished": 0,
"results_file": "/home/dockeradmin/.ansible_async/229361279978.5796",
"started": 1
}
}
I wanted to ask if this is an intended behavior ? What i understood with async is that it will always move to the next task and poll value will determine when to check back and then use the outcomes in async_status or something. Or is it that async with non zero poll is blocking but internally it is doing things differently ?