Basically I have a simple server name ( non FQDN ) and im trying to identify in which DNS zone it has A record
We have multiple DNS zones in our environment.
As i cant rely on PTR records im trying to use DIG module to look for a A record with zone name as variable. Once the A record is found, i want to use that zone name. Unfortunately im not able to put all the above together in ansible code
i've tried following
- name:
set_fact:
found: "{{found+[ lookup('dig', ('{{ dns_name }}.{{item.1}}'), 'qtype=A' , flat=0)] }}"
domain: "{{ item.0 }}"
with_indexed_items:
- zone1.com
- zone2.com
- zone3.com
ok: [xxxxxxxxxxxxxxxxxxxx] => {
"found": [
"10.10.10.10",
"NXDOMAIN",
"NXDOMAIN"]}
This generates the list of items but i dont know how to match these items with the list of zones or how to add the index into this list.
Any help would be very welcome