当库存中没有任何主机时,运行剧本时只会发出警告:
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'是否有一种方法来制造错误而不是警告?
我发现ansible.cfg中有这个参数:
[inventory]
unparsed_is_failed = True但只有当没有您要使用的库存文件时,它才会返回错误。它没有调查内容。
发布于 2020-04-03 09:45:56
警告:如果主机列表为空,则只有本地主机可用。请注意,隐式localhost与“all”不匹配。
问:"Is有一种方法来制造错误,而不是Warning?"
答:是的。它是。在剧本里试一试。例如
- hosts: localhost
tasks:
- fail:
msg: "[ERROR] Empty inventory. No host available."
when: groups.all|length == 0
- hosts: all
tasks:
- debug:
msg: Playbook started空置的存货
致命:本地主机:失败!=> {“已更改”:false,"msg":“错误空库存。没有可用主机”}
。
https://stackoverflow.com/questions/61008355
复制相似问题