how to set timeout for shell command

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

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

Thanks in advance,
Justin

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!

Hi