问题描述
我有一个场景,可以在清单中的2-3台主机上运行剧本,因此,当我满足某些条件时,我将设置一个主机变量,但最终,我想基于每个失败的主机传递/失败执行。如果任何主机失败,则应该使整个执行失败,而不是单个执行失败 任何想法都在此先感谢。
- hosts: lab_group
gather_facts: false
tasks:
- include: "plays.yml"
- debug:
msg: PASS
with_items: "{{ groups['lab_group'] }}"
when: hostvars[item].node_pass == true
run_once: true
解决方案:
- hosts: lab_group
any_errors_fatal: true
gather_facts: false
tasks:
- include: "plays.yml"
- debug:
msg: PASS
with_items: "{{ groups['lab_group'] }}"
when: hostvars[item].node_pass == true
register: passcheck
run_once: true
- fail:
msg: FAIL
with_items: "{{ groups['lab_group'] }}"
when: hostvars[item].node_pass == false or
hostvars[item].node_pass == ""
run_once: true
因此此标签any_errors_fatal: true
将使剧本的整个结果都失败。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)