# Ansible Playbook - when: list?

**URL:** <https://forum.ansible.com/t/ansible-playbook-when-list/23065>\
**Category:** Ansible Project\
**Created:** [November 21, 2016, 6:14pm UTC](https://forum.ansible.com/t/ansible-playbook-when-list/23065 "2016-11-21T18:14:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeffrey\_Wen](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@Jeffrey\_Wen](https://forum.ansible.com/u/Jeffrey_Wen)\
**Post date:** [November 21, 2016, 6:14pm UTC](https://forum.ansible.com/t/ansible-playbook-when-list/23065/1 "2016-11-21T18:14:58Z")

</div>

`  
localhost | SUCCESS =\> {  
“ansible\_facts”: {  
“ansible\_dns”: {  
“nameservers”: [  
“192.168.1.1”,  
“192.168.1.2”  
],  
“search”: [  
“[example.com](http://example.com)”,  
]  
}  
},  
“changed”: false  
}

`

**I am trying to reference my nameservers but I am running into syntactical issues. I cannot find any docs online that show me how to access a list from gathering facts.**

I have tried the following:

`

- 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.1’ and ansible\_dns == nameservers == ‘192.168.1.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.1’ and nameservers == ‘192.168.1.2’  
`

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [November 22, 2016, 5:53pm UTC](https://forum.ansible.com/t/ansible-playbook-when-list/23065/2 "2016-11-22T17:53:18Z")

</div>

when: '192.168.1.1' in ansible\_dns.nameservers and '192.168.1.2' in  
ansible\_dns.nameservers

---

<div class="post-metadata">

**Author:** ![Jeffrey\_Wen](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@Jeffrey\_Wen](https://forum.ansible.com/u/Jeffrey_Wen)\
**Post date:** [November 22, 2016, 6:26pm UTC](https://forum.ansible.com/t/ansible-playbook-when-list/23065/3 "2016-11-22T18:26:42Z")

</div>

Thank you!
