问题描述
我有以下建议的剧本代码,以检查库存主机是否可访问。
---
- hosts: "{{ENV}}_*"
user: "{{USER}}"
tasks:
- fail:
msg: "Server is UNREACHABLE."
when: hostvars[item].ansible_facts|list|length == 0
with_items: "{{ ansible_play_hosts }}"
我在运行剧本时遇到以下错误:
TASK [] ****************************************
fatal: [remotehost.com]: FAILED! => {"msg": "The conditional check 'hostvars[item].ansible_facts|list|length == 0' failed. The error was: error while evaluating conditional (hostvars[item].ansible_facts|list|length == 0): 'dict object' has no attribute 'ansible_facts'\n\nThe error appears to have been in '/web/aes/admin/playbooks/restart.yml': line 9,column 10,but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - fail\n ^ here\n"}
需要有关如何修复此错误的建议?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)