让我们考虑以下伪 ansible 代码:
- 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"
Run Code Online (Sandbox Code Playgroud)
可以用ansible来做吗?
阅读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"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7473 次 |
| 最近记录: |