如果一个游戏失败,如何停止剧本
问题描述:
我有以下剧本3次。当其中一场比赛失败时,接下来的比赛仍然执行。我想这是因为我用不同的主机目标来运行这些游戏。如果一个游戏失败,如何停止剧本
我想避免这种情况,并在剧本失败时让剧本停止,这有可能吗?
---
- name: create the EC2 instances
hosts: localhost
any_errors_fatal: yes
connection: local
tasks:
- ...
- name: configure instances
hosts: appserver
any_errors_fatal: yes
gather_facts: true
tasks:
- ...
- name: Add to load balancer
hosts: localhost
any_errors_fatal: yes
vars:
component: travelmatrix
tasks:
- ...
答
如果存在任何错误,您可以使用any_errors_fatal停止播放。
- name: create the EC2 instances
hosts: localhost
connection: local
any_errors_fatal: true
tasks:
- ...
这不起作用,因为'any_errors_fatal'标记只在剧中的主机为失败,但接下来的比赛适用于不同的主机(它实际上适用于本地主机)。我已经更新了问题中的剧本,表明已经设置了“any_error_fatals”。 – David
对不起,我没有正确测试。你的回答是对的。 SO目前不让我删除-1,但我会接受答案。 – David