Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to set timeout in Ansible shell module

Tags:

ansible

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"

like image 418
salene Avatar asked Mar 13 '26 20:03

salene


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
like image 119
altair66 Avatar answered Mar 16 '26 03:03

altair66



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!