如何解决Ansible:评估条件时出错
我在这本剧本上做错了什么?
$ cat check_only_centos7_tmp.yml
- hosts: myhosts
become: yes
gather_facts: no
tasks:
- name: Check Uptime
command: uptime
when: ansible_distribution == "CentOS"
错误:
fatal: [server.myhost.com]: FAILED! => {"msg": "The conditional check 'ansible_distribution == \"CentOS\"' failed. The error was: error while evaluating conditional (ansible_distribution == \"CentOS\"): 'ansible_distribution' is undefined\n\nThe error appears to be in '/home/user/ansible_playbooks/check_only_centos7_tmp.yml': line 11,column 11,but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Check Uptime\n ^ here\n"}
解决方法
因为你没有 gather_facts: true
ansible 不知道什么是 ansible_distribution
值。它是从托管主机发现的。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。