我正在我的本地主机上收集事实。
localhost | SUCCESS => {
"ansible_facts": {
"ansible_dns": {
"nameservers": [
"192.168.1.2",
"192.168.1.3"
],
"search": [
"example.com",
]
}
},
"changed": false
}我需要能够访问名称服务器:192.168.1.2和192.168.1.3
我已经尝试了以下操作,但语法仍然出现了错误。我没有看到任何在线文档向我展示如何访问嵌套值。
# Method 1
- name: Allow httpd access to files on CIFS volumes that are labeled with the cifs_t type
seboolean: name=httpd_use_cifs state=true persistent=yes
when: ansible_dns == nameservers == '192.168.1.2' and ansible_dns == nameservers == '192.168.1.3'
# Method 2
- name: Allow httpd access to files on CIFS volumes that are labeled with the cifs_t type
seboolean: name=httpd_use_cifs state=true persistent=yes
when: nameservers == '192.168.1.2' and nameservers == '192.168.1.3'发布于 2016-11-21 18:34:18
您可以使用点:ansible_dns.nameservers访问嵌套元素。
不确定要构造什么条件,但其中一种可能的方法是:
when: "'192.168.1.2' in ansible_dns.nameservers and '192.168.1.3' in ansible_dns.nameservers"
https://stackoverflow.com/questions/40726846
复制相似问题