Unable to set timeout in Ansible shell module

Viewed 8012

I tried to set timout in Ansible shell module however it is not working. If i execute same in terminal it is working. Below is my code

- name: Timeout
  shell: "timeout 30s {{ execute_path_nityo }}/execute.sh"

1 Answers
  - name: Simulate long running op (15 sec),wait for up to 30 sec,poll every 5sec
    shell: "{{ execute_path_nityo }}/execute.sh"
    async: 30
    poll: 5

If you want to set a longer timeout limit for a certain task in your playbook, use async with poll set to a positive value. Ansible will still block the next task in your playbook, waiting until the async task either completes, fails or times out. However, the task will only time out if it exceeds the timeout limit you set with the async parameter.

    - name: Execute the script
      shell: "/tmp/script.sh 60" # Run for 60 seconds 
      async: 120 # Maximum allowed time in Seconds
      poll: 10 # Polling Interval in Seconds
Related