首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ansible Playbook语法问题-什么时候:列表

Ansible Playbook语法问题-什么时候:列表
EN

Stack Overflow用户
提问于 2016-11-21 18:19:34
回答 1查看 481关注 0票数 0

我正在我的本地主机上收集事实。

代码语言:javascript
复制
localhost | SUCCESS => {
    "ansible_facts": {
        "ansible_dns": {
            "nameservers": [
                "192.168.1.2", 
                "192.168.1.3"
            ], 
            "search": [
                "example.com", 
            ]
        }
    }, 
    "changed": false
}

我需要能够访问名称服务器:192.168.1.2192.168.1.3

我已经尝试了以下操作,但语法仍然出现了错误。我没有看到任何在线文档向我展示如何访问嵌套值。

代码语言:javascript
复制
# 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'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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"

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40726846

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档