我正在尝试在某些主机不可达时打印自定义消息。我的问题是,当主机不可达时,它将在下一个任务中被跳过,因此失败模块永远不会被触发。
而可达的主机也会由于when条件未满足
而跳过任务。
我尝试了ignore_unreachable: false
,但仍然一样。
任何想法都将不胜感激。
---
- hosts: prod
gather_facts: no
tasks:
- name: fail when not reachable
action: ping
register: ping_result
# any_errors_fatal: true
- fail:
msg: "please make sure all server up and run again"
when: ping_result.unreachable is defined
any_errors_fatal: true