我尝试在 Ansible shell 模块中设置超时,但它不起作用。如果我在终端中执行相同的操作,它就可以工作。下面是我的代码
- name: Timeout
shell: "timeout 30s {{ execute_path_nityo }}/execute.sh"
Run Code Online (Sandbox Code Playgroud)
alt*_*r66 12
- 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
Run Code Online (Sandbox Code Playgroud)
如果您想为 playbook 中的某个任务设置更长的超时限制,请使用 async 并将 poll 设置为正值。Ansible 仍会阻止 playbook 中的下一个任务,等待异步任务完成、失败或超时。但是,只有当任务超过您使用 async 参数设置的超时限制时,任务才会超时。
- 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17115 次 |
| 最近记录: |