Hi Brian, above playbook is for running a task on multiple hosts.
Here is example of my playbook.
$ cat parallel.yaml
below is playbook output.
Check for start time of each loop iteration. Since date & echo command takes less time you will see stdout_lines with millisecond difference.
Each loop iteration is takes place in sequence( rather after completion first one) that is what i am observing
Assume that if we replaces echo/date commands with commands/script which takes more than 3 min. so each iteration will take 3 min. If we have loop of 50 count.
$ ansible-playbook parallel.yaml
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’
PLAY [localhost] ***************************************************************************************************************************************************************************************************
TASK [Register loop output as a variable] **************************************************************************************************************************************************************************
changed: [localhost] => (item=one)
changed: [localhost] => (item=two)
changed: [localhost] => (item=three)
TASK [Print output] ************************************************************************************************************************************************************************************************
ok: [localhost] => {
“echo.results”: [
{
“ansible_loop_var”: “item”,
“changed”: true,
“cmd”: “date +%s%N ;echo one”,
“delta”: “0:00:00.007693”,
“end”: “2025-01-24 09:36:44.703260”,
“failed”: false,
“invocation”: {
“module_args”: {
“_raw_params”: “date +%s%N ;echo one”,
“_uses_shell”: true,
“argv”: null,
“chdir”: null,
“creates”: null,
“executable”: null,
“removes”: null,
“stdin”: null,
“stdin_add_newline”: true,
“strip_empty_ends”: true
}
},
“item”: “one”,
“msg”: “”,
“rc”: 0,
“start”: “2025-01-24 09:36:44.695567”,
“stderr”: “”,
“stderr_lines”: ,
“stdout”: “1737740204N\none”,
“stdout_lines”: [
“1737740204N”,
“one”
]
},
{
“ansible_loop_var”: “item”,
“changed”: true,
“cmd”: “date +%s%N ;echo two”,
“delta”: “0:00:00.007824”,
“end”: “2025-01-24 09:36:44.911104”,
“failed”: false,
“invocation”: {
“module_args”: {
“_raw_params”: “date +%s%N ;echo two”,
“_uses_shell”: true,
“argv”: null,
“chdir”: null,
“creates”: null,
“executable”: null,
“removes”: null,
“stdin”: null,
“stdin_add_newline”: true,
“strip_empty_ends”: true
}
},
“item”: “two”,
“msg”: “”,
“rc”: 0,
“start”: “2025-01-24 09:36:44.903280”,
“stderr”: “”,
“stderr_lines”: ,
“stdout”: “1737740204N\ntwo”,
“stdout_lines”: [
“1737740204N”,
“two”
]
},
{
“ansible_loop_var”: “item”,
“changed”: true,
“cmd”: “date +%s%N ;echo three”,
“delta”: “0:00:00.007903”,
“end”: “2025-01-24 09:36:45.115974”,
“failed”: false,
“invocation”: {
“module_args”: {
“_raw_params”: “date +%s%N ;echo three”,
“_uses_shell”: true,
“argv”: null,
“chdir”: null,
“creates”: null,
“executable”: null,
“removes”: null,
“stdin”: null,
“stdin_add_newline”: true,
“strip_empty_ends”: true
}
},
“item”: “three”,
“msg”: “”,
“rc”: 0,
“start”: “2025-01-24 09:36:45.108071”,
“stderr”: “”,
“stderr_lines”: ,
“stdout”: “1737740205N\nthree”,
“stdout_lines”: [
“1737740205N”,
“three”
]
}
]
}
PLAY RECAP *********************************************************************************************************************************************************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0