让我们考虑以下伪可运行代码:
- 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中做吗?
答案 0 :(得分:0)
阅读Ansible Blocks上的文档,它们使您可以做类似的事情:
- 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"