角色中的 Ansible 块未按预期运行
Ansible block in role not acting as expected
我有 ansible 2.2.1.0,我有这个角色:
- block:
- shell: echo 1
- shell: fail
- shell: echo 2
rescue:
- shell: echo 3
always:
- shell: echo 4
- name: running something after the block
shell: echo 5
如果我 运行 这个角色,块的第一部分会因为 "fail" 命令(不存在 :) "stderr: /bin/sh: 1: fail: not found")而失败所以救援踢 + 总是.但是最后一个任务,那个 "running something after the block" 从来没有 运行s。剧终了!
这是为什么?
我认为的预期结果是:如果块的第一部分失败,救援就会启动 + 总是(如果有的话),然后继续播放 运行 其余的任务。
文档中没有关于此的内容。
有解决办法吗?
这是 2.2.1 中的 bug。如果这是您需要的工作流程,请降级到 2.2.0。
我有 ansible 2.2.1.0,我有这个角色:
- block:
- shell: echo 1
- shell: fail
- shell: echo 2
rescue:
- shell: echo 3
always:
- shell: echo 4
- name: running something after the block
shell: echo 5
如果我 运行 这个角色,块的第一部分会因为 "fail" 命令(不存在 :) "stderr: /bin/sh: 1: fail: not found")而失败所以救援踢 + 总是.但是最后一个任务,那个 "running something after the block" 从来没有 运行s。剧终了!
这是为什么? 我认为的预期结果是:如果块的第一部分失败,救援就会启动 + 总是(如果有的话),然后继续播放 运行 其余的任务。
文档中没有关于此的内容。
有解决办法吗?
这是 2.2.1 中的 bug。如果这是您需要的工作流程,请降级到 2.2.0。