[miksan@ponderstibbons ansible]$ ansible --version
ansible 1.6.10
[miksan@ponderstibbons ansible]$ time ansible-playbook background.yml
PLAY [localhost] **************************************************************
TASK: [run shellscript] *******************************************************
changed: [localhost]
TASK: [debug var=sleep.stdout_lines] ******************************************
ok: [localhost] => {
"sleep.stdout_lines": [
"Kicking off other script at Thu Sep 25 10:54:38 CEST 2014",
"All finished. Returned from other script at Thu Sep 25 10:54:38 CEST 2014", # <--- kickoff.sh finishes, but waits for sleep.sh to finish
"Starting /tmp/sleep.sh at Thu Sep 25 10:54:38 CEST 2014", # <-- sleep.sh starts (in the background)
"Sleeping 30 seconds",
"/tmp/sleep.sh Woke up",
"Sleeping another 30 seconds",
"/tmp/sleep.sh Done. Exiting /tmp/sleep.sh at Thu Sep 25 10:55:38 CEST 2014" # <--- sleep.sh finishes
]
}
PLAY RECAP ********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0
real 1m0.288s
user 0m0.147s
sys 0m0.039s[miksan@ponderstibbons ansible]$ ansible --version
ansible 1.7.2
[miksan@ponderstibbons ansible]$ time ansible-playbook background.yml
PLAY [localhost] **************************************************************
TASK: [run shellscript] *******************************************************
changed: [localhost]
TASK: [debug var=sleep.stdout_lines] ******************************************
ok: [localhost] => {
"sleep.stdout_lines": [
"Kicking off other script at Thu Sep 25 10:45:15 CEST 2014",
"All finished. Returned from other script at Thu Sep 25 10:45:15 CEST 2014", # <--- kickoff.sh finishes but doesnt wait for sleep.sh to finish
"Starting /tmp/sleep.sh at Thu Sep 25 10:45:15 CEST 2014", # <--- sleep.sh starts (in the background) but never gets to finish
"Sleeping 30 seconds"
]
}
PLAY RECAP ********************************************************************
localhost : ok=2 changed=1 unreachable=0 failed=0
real 0m1.291s
user 0m0.148s
sys 0m0.034sHi Mikael,
This is not a bug, as the module can only assume that when the script returns that the task is finished - it has no way of knowing if the script started background or child processes. And even if it did, it would not know whether it should wait for those to exit or not (think of a script which starts a daemonized process).
So for your situation, I would say to modify the script to wait until its tasks are complete or to use async, as you noted.
Thanks!
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/700a7a8f-0d10-4ba2-99b5-f35554b7b405%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/22d0a022-0987-419d-b24b-bb481ded65ba%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/64f128c1-8e10-4d01-ad68-2f6303c1144c%40googlegroups.com.