community / community.dns / 2.8.3 / lookup / lookup_as_dict Look up DNS records as dictionaries | "added in version" 2.6.0 of community.dns" Authors: Felix Fontein (@felixfontein)community.dns.lookup_as_dict (2.8.3) — lookup
Install with ansible-galaxy collection install community.dns:==2.8.3
collections: - name: community.dns version: 2.8.3
Look up DNS records and return them as interpreted dictionaries.
- name: Look up A (IPv4) records for example.org as a list of dictionaries ansible.builtin.debug: msg: "{{ query('community.dns.lookup_as_dict', 'example.org.') }}"
- name: Look up AAAA (IPv6) records for example.org as a list of IPv6 addresses ansible.builtin.debug: msg: "{{ query('community.dns.lookup_as_dict', 'example.org.', type='AAAA' ) | map(attribute='address') }}"
- name: Look up TXT records for ansible.com as a list of strings ansible.builtin.debug: msg: "{{ query('community.dns.lookup_as_dict', 'ansible.com.', type='TXT' ) | map(attribute='value') }}"
type: choices: - A - ALL - AAAA - CAA - CNAME - DNAME - DNSKEY - DS - HINFO - LOC - MX - NAPTR - NS - NSEC - NSEC3 - NSEC3PARAM - PTR - RP - RRSIG - SOA - SPF - SRV - SSHFP - TLSA - TXT default: A description: - The record type to retrieve. type: str _terms: description: - Domain name(s) to query. elements: str required: true type: list server: description: - The DNS server(s) to use to look up the result. Must be a list of one or more IP addresses. - By default, the system's standard resolver is used. elements: str type: list query_retry: default: 3 description: - Number of retries for DNS query timeouts. type: int query_timeout: default: 10 description: - Timeout per DNS query in seconds. type: float servfail_retries: default: 0 description: - How often to retry on SERVFAIL errors. type: int nxdomain_handling: choices: - empty - fail default: empty description: - How to handle NXDOMAIN errors. These appear if an unknown domain name is queried. - V(empty) (default) returns an empty result for that domain name. This means that for the corresponding domain name, nothing is added to RV(_result). - V(fail) makes the lookup fail. type: str
_result: contains: address: description: - A IPv4 respectively IPv6 address. returned: if O(type=A) or O(type=AAAA) type: str algorithm: description: - The algorithm ID. returned: if O(type=DNSKEY) or O(type=DS) or O(type=NSEC3) or O(type=NSEC3PARAM) or O(type=RRSIG) or O(type=SSHFP) type: int altitude: description: - The altitude. returned: if O(type=LOC) type: float cert: description: - The certificate. returned: if O(type=TLSA) type: str cpu: description: - The CPU. returned: if O(type=HINFO) type: str digest: description: - The digest. returned: if O(type=DS) type: str digest_type: description: - The digest's type. returned: if O(type=DS) type: int exchange: description: - The exchange server. returned: if O(type=MX) type: str expiration: description: - The expiration Unix timestamp. returned: if O(type=RRSIG) type: int expire: description: - Number of seconds after which secondary name servers should stop answering request for this zone if the main name server does not respond. returned: if O(type=SOA) type: int fingerprint: description: - The fingerprint. returned: if O(type=SSHFP) type: str flags: description: - Flags. - This is actually of type C(string) for O(type=NAPTR). returned: if O(type=CAA) or O(type=DNSKEY) or O(type=NAPTR) or O(type=NSEC3) or O(type=NSEC3PARAM) type: int fp_type: description: - The fingerprint's type. returned: if O(type=SSHFP) type: int horizontal_precision: description: - The horizontal precision of the location. returned: if O(type=LOC) type: float inception: description: - The inception Unix timestamp. returned: if O(type=RRSIG) type: int iterations: description: - The number of iterations. returned: if O(type=NSEC3) or O(type=NSEC3PARAM) type: int key: description: - The key. returned: if O(type=DNSKEY) type: str key_tag: description: - The key's tag. returned: if O(type=DS) or O(type=RRSIG) type: int labels: description: - The labels. returned: if O(type=RRSIG) type: int latitude: description: - The location's latitude. elements: int returned: if O(type=LOC) type: list longitude: description: - The location's longitude. elements: int returned: if O(type=LOC) type: list mbox: description: - The mbox. returned: if O(type=RP) type: str minimum: description: - Used to calculate the TTL for purposes of negative caching. returned: if O(type=SOA) type: int mname: description: - Primary main name server for this zone. returned: if O(type=SOA) type: str mtype: description: - The mtype. returned: if O(type=TLSA) type: int next: description: - The next value. returned: if O(type=NSEC) or O(type=NSEC3) type: str order: description: - The order value. returned: if O(type=NAPTR) type: int original_ttl: description: - The original TTL. returned: if O(type=RRSIG) type: int os: description: - The operating system. returned: if O(type=HINFO) type: str port: description: - The port. returned: if O(type=SRV) type: int preference: description: - The preference value for this record. returned: if O(type=MX) or O(type=NAPTR) type: int priority: description: - The priority value for this record. returned: if O(type=SRV) type: int protocol: description: - The protocol. returned: if O(type=DNSKEY) type: int refresh: description: - Number of seconds after which secondary name servers should query the main name server for the SOA record to detect zone changes. returned: if O(type=SOA) type: int regexp: description: - A regular expression. returned: if O(type=NAPTR) type: str replacement: description: - The replacement. returned: if O(type=NAPTR) type: str retry: description: - Number of seconds after which secondary name servers should retry to request the serial number from the main name server if the main name server does not respond. returned: if O(type=SOA) type: int rname: description: - E-mail address of the administrator responsible for this zone. returned: if O(type=SOA) type: str salt: description: - The salt. returned: if O(type=NSEC3) or O(type=NSEC3PARAM) type: str selector: description: - The selector. returned: if O(type=TLSA) type: int serial: description: - Serial number for this zone. returned: if O(type=SOA) type: int service: description: - The service. returned: if O(type=NAPTR) type: str signature: description: - The signature. returned: if O(type=RRSIG) type: str signer: description: - The signer. returned: if O(type=RRSIG) type: str size: description: - The size of the location. returned: if O(type=LOC) type: float strings: description: - List of strings for this record. - See RV(_result[].value) for the concatenated result. elements: str returned: if O(type=SPF) or O(type=TXT) type: list tag: description: - The tag. returned: if O(type=CAA) type: str target: description: - The target. returned: if O(type=CNAME) or O(type=DNAME) or O(type=NS) or O(type=PTR) or O(type=SRV) type: str txt: description: - The TXT value. returned: if O(type=RP) type: str type_covered: description: - The type covered. returned: if O(type=RRSIG) type: str usage: description: - The usage flag. returned: if O(type=TLSA) type: int value: description: - The value. - For O(type=SPF) or O(type=TXT), this is the concatenation of RV(_result[].strings). returned: if O(type=CAA) or O(type=SPF) or O(type=TXT) type: str vertical_precision: description: - The vertical precision of the location. returned: if O(type=LOC) type: float weight: description: - The service's weight. returned: if O(type=SRV) type: int windows: description: - The windows. returned: if O(type=NSEC) or O(type=NSEC3) type: str description: - The records of type O(type) for all queried DNS names. - If multiple DNS names are queried in O(_terms), the resulting lists have been concatenated. - Depending on O(type), different fields are returned. - For O(type=TXT) and O(type=SPF), also the concatenated value is returned as RV(_result[].value). elements: dict sample: - address: 127.0.0.1 type: list