尝试捕获在ansible与任务超时

问题描述 投票:0回答:1

让我们考虑下面的伪代码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"

是否有可能在ansible办?

ansible
1个回答
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"
© www.soinside.com 2019 - 2024. All rights reserved.