2016-11-21 5 views
0

내 로컬 호스트에서 사실을 수집 중입니다.가능성있는 플레이 북 구문 문제 - when : list

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을. 중첩 된 값에 액세스하는 방법을 보여주는 온라인 문서가 없습니다. ansible_dns.nameservers :

# 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' 

답변

0

당신은 와 중첩 된 요소에 액세스 할 수 있습니다.

당신이 구축하고자하는 어떤 조건을 확인하지만, 가능한 방법 중 하나를 사용하지 않음 :
when: "'192.168.1.2' in ansible_dns.nameservers and '192.168.1.3' in ansible_dns.nameservers"

+0

사실'ansible_dns.nameservers == '192.168.1.7'' 사용. 당신의 방법도 효과가있을 것이라고 확신합니다! ''ansible local -m setup -a 'filter = ansible_dns.nameservers' '를 필터링 할 때,. (점)이 작동하지 않으면 플레이 북에서 작동하지 않는다고 가정했습니다. –

+0

편집 : 농담. 귀하의 "안에"진술서가 작동하고 광산 않습니다 :) –