Note
This plugin is part of the community.general collection.
To install it use: ansible-galaxy collection install community.general.
To use it in a playbook, specify: community.general.dig.
The below requirements are needed on the local controller node that executes this lookup.
| Parameter | Choices/Defaults | Configuration | Comments |
|---|---|---|---|
| _terms string | domain(s) to query | ||
| flat string | Default: 1 | If 0 each record is returned as a dictionary, otherwise a string | |
| qtype string |
| record type to query |
Note
- name: Simple A record (IPV4 address) lookup for example.com
ansible.builtin.debug:
msg: "{{ lookup('community.general.dig', 'example.com.')}}"
- name: "The TXT record for example.org."
ansible.builtin.debug:
msg: "{{ lookup('community.general.dig', 'example.org.', 'qtype=TXT') }}"
- name: "The TXT record for example.org, alternative syntax."
ansible.builtin.debug:
msg: "{{ lookup('community.general.dig', 'example.org./TXT') }}"
- name: use in a loop
ansible.builtin.debug:
msg: "MX record for gmail.com {{ item }}"
with_items: "{{ lookup('community.general.dig', 'gmail.com./MX', wantlist=True) }}"
- ansible.builtin.debug:
msg: "Reverse DNS for 192.0.2.5 is {{ lookup('community.general.dig', '192.0.2.5/PTR') }}"
- ansible.builtin.debug:
msg: "Reverse DNS for 192.0.2.5 is {{ lookup('community.general.dig', '5.2.0.192.in-addr.arpa./PTR') }}"
- ansible.builtin.debug:
msg: "Reverse DNS for 192.0.2.5 is {{ lookup('community.general.dig', '5.2.0.192.in-addr.arpa.', 'qtype=PTR') }}"
- ansible.builtin.debug:
msg: "Querying 198.51.100.23 for IPv4 address for example.com. produces {{ lookup('dig', 'example.com', '@198.51.100.23') }}"
- ansible.builtin.debug:
msg: "XMPP service for gmail.com. is available at {{ item.target }} on port {{ item.port }}"
with_items: "{{ lookup('community.general.dig', '_xmpp-server._tcp.gmail.com./SRV', 'flat=0', wantlist=True) }}"
Common return values are documented here, the following are the fields unique to this lookup:
| Key | Returned | Description | |
|---|---|---|---|
| _list list / elements=raw | success | List of composed strings or dictionaries with key and value If a dictionary, fields shows the keys returned depending on query type | |
| A string | success | address | |
| AAAA string | success | address | |
| ALL string | success | owner, ttl, type | |
| CNAME string | success | target | |
| DLV string | success | algorithm, digest_type, key_tag, digest | |
| DNAME string | success | target | |
| DNSKEY string | success | flags, algorithm, protocol, key | |
| DS string | success | algorithm, digest_type, key_tag, digest | |
| HINFO string | success | cpu, os | |
| LOC string | success | latitude, longitude, altitude, size, horizontal_precision, vertical_precision | |
| MX string | success | preference, exchange | |
| NAPTR string | success | order, preference, flags, service, regexp, replacement | |
| NS string | success | target | |
| NSEC3PARAM string | success | algorithm, flags, iterations, salt | |
| PTR string | success | target | |
| RP string | success | mbox, txt | |
| SOA string | success | mname, rname, serial, refresh, retry, expire, minimum | |
| SPF string | success | strings | |
| SRV string | success | priority, weight, port, target | |
| SSHFP string | success | algorithm, fp_type, fingerprint | |
| TLSA string | success | usage, selector, mtype, cert | |
| TXT string | success | strings | |
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.10/collections/community/general/dig_lookup.html