how to set timeout for shell command

5,201 views
Skip to first unread message

Justin Jinsik Kim

unread,
Sep 15, 2014, 11:36:59 AM9/15/14
to ansible...@googlegroups.com
Hi,

I want to define response waiting time limit for all shell commands on ansible-playbook


test.yml:
....
- name: want to quit if it doesn't get response in 5 secs
  shell: "sleep 100"

- name: want to quit if it doesn't get response in 5 secs
  shell: "sleep 200"

- name: want to quit if it doesn't get response in 5 secs
  shell: "sleep 300"

....



I know I can use async method for each task but is there any simple way to do this for all shell module command?

I've tried this but it didn't work

ex> ansible-playbook test.yml .... -T 50
ex> add timeout=10 on ansible.cfg


Thanks in advance,
Justin

James Cammarata

unread,
Sep 15, 2014, 4:34:00 PM9/15/14
to ansible...@googlegroups.com
Hi Justin, currently there is no general purpose timeout parameter for shell/commands, so the use of async as you've noted is the proper way to limit the execution time of a long-running task.

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/e942c4a7-c017-461d-a99b-956ccf9b5926%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Karl E. Jorgensen

unread,
Sep 22, 2014, 4:52:35 AM9/22/14
to ansible...@googlegroups.com
Hi
There is also the shell command "timeout" (in Debian this is in the
coreutils package, not sure about other distros) - which can enforce a
timeout on a given shell command.

Perhaps that can help too?

--
Karl E. Jorgensen
Reply all
Reply to author
Forward
0 new messages