Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
794 views
in Technique[技术] by (71.8m points)

Unable to set timeout in Ansible shell module

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"

question from:https://stackoverflow.com/questions/66046989/unable-to-set-timeout-in-ansible-shell-module

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  - 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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...