Ansible Playbook - when: list?

`
localhost | SUCCESS => {
“ansible_facts”: {
“ansible_dns”: {
“nameservers”: [
“192.168.1.1”,
“192.168.1.2”
],
“search”: [
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’
    `

when: '192.168.1.1' in ansible_dns.nameservers and '192.168.1.2' in
ansible_dns.nameservers

Thank you!