community.dns.lookup (2.8.3) — lookup

Look up DNS records

| "added in version" 2.6.0 of community.dns"

Authors: Felix Fontein (@felixfontein)

Install collection

Install with ansible-galaxy collection install community.dns:==2.8.3


Add to requirements.yml

  collections:
    - name: community.dns
      version: 2.8.3

Description

Look up DNS records.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Look up A (IPv4) records for example.org
  ansible.builtin.debug:
    msg: "{{ query('community.dns.lookup', 'example.org.') }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Look up AAAA (IPv6) records for example.org
  ansible.builtin.debug:
    msg: "{{ query('community.dns.lookup', 'example.org.', type='AAAA' ) }}"

Inputs

    
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
    - message
    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.
    - V(message) adds the string V(NXDOMAIN) to RV(_result).
    type: str

Outputs

_result:
  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.
  elements: str
  sample:
  - 127.0.0.1
  type: list