在任务超时的情况下尝试捕获 [英] Try-Catch in ansible with timeout on task
本文介绍了在任务超时的情况下尝试捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们考虑以下伪可运行代码:
Let's consider following pseudo-ansible code:
- name: "some long task which can hang
- command: "something"
- timeout: 60s
- name: "catch in case of failure (in particularity timeout)"
- command: "some helpful debug command"
可以在ansible中做吗?
Is it possible to do in ansible?
推荐答案
Read the docs on Ansible Blocks They allow you to amongst other things do stuff like:
- block:
- debug:
msg: "This is a basic task that will run in the block"
rescue:
- debug:
msg: "This task will only run if something fails in the main block
always:
- debug:
msg: "This task always runs, irrespective of whether the tasks in the main block succeed or not"
这篇关于在任务超时的情况下尝试捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文