cat /tmp/kickoff.sh
#!/bin/bash
echo "Kicking off other script at `date`"
sh /tmp/sleep.sh 30 &
echo "All finished. Returned from other script at `date`"
cat /tmp/sleep.sh
#!/bin/bash
echo "Starting $0 at `date`"
echo "Sleeping $1 seconds"
sleep $1
echo "$0 Woke up"
echo "Sleeping another $1 seconds"
sleep $1
echo "$0 Done. Exiting $0 at `date`"
---
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: run shellscript
shell: /tmp/kickoff.sh
register: sleep
- debug: var=sleep.stdout_lines[miksan@ponderstibbons ansible]$ ansible --versionansible 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", # <--- Exits the kickoff script, but it 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.288suser 0m0.147ssys 0m0.039s[miksan@ponderstibbons ansible]$[miksan@ponderstibbons ansible]$ ansible --versionansible 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", # <--- Exists kickoff.sh, doesnt wait for sleep.sh to finish "Starting /tmp/sleep.sh at Thu Sep 25 10:45:15 CEST 2014", # <--- sleep.sh starts, but never gets to finish "Sleeping 30 seconds" ]}
PLAY RECAP ******************************************************************** localhost : ok=2 changed=1 unreachable=0 failed=0
real 0m1.291suser 0m0.148ssys 0m0.034s
--
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/ccdf0c2f-d3f5-4252-b586-5d8874b5260b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.