community.dns.nameserver_info module – Look up nameservers for a DNS name

Note

This module is part of the community.dns collection (version 2.9.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.dns. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: community.dns.nameserver_info.

New in community.dns 2.6.0

Synopsis

  • Retrieve all nameservers that are responsible for a DNS name.

Requirements

The below requirements are needed on the host that executes this module.

  • dnspython >= 1.15.0 (maybe older versions also work)

Parameters

Parameter

Comments

always_ask_default_resolver

boolean

When set to true (default), will use the default resolver to find the authoritative nameservers of a subzone. See server for how to configure the default resolver.

When set to false, will use the authoritative nameservers of the parent zone to find the authoritative nameservers of a subzone. This only makes sense when the nameservers were recently changed and have not yet propagated.

Choices:

  • false

  • true ← (default)

name

list / elements=string / required

A list of DNS names whose nameservers to retrieve.

query_retry

integer

Number of retries for DNS query timeouts.

Default: 3

query_timeout

float

Timeout per DNS query in seconds.

Default: 10.0

resolve_addresses

boolean

Whether to resolve the nameserver names to IP addresses.

Choices:

  • false ← (default)

  • true

server

list / elements=string

added in community.dns 2.7.0

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.

servfail_retries

integer

How often to retry on SERVFAIL errors.

Default: 0

Attributes

Attribute

Support

Description

check_mode

Support: full

This action does not modify state.

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: N/A

This action does not modify state.

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Examples

- name: Retrieve name servers of two DNS names
  community.dns.nameserver_info:
    name:
      - www.example.com
      - example.org
  register: result

- name: Show nameservers for www.example.com
  ansible.builtin.debug:
    msg: '{{ result.results[0].nameserver }}'

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

results

list / elements=dictionary

Information on the nameservers for every DNS name provided in name.

Returned: always

Sample: [{"name": "www.example.com", "nameservers": ["ns1.example.com", "ns2.example.com"]}, {"name": "example.org", "nameservers": ["ns1.example.org", "ns2.example.org", "ns3.example.org"]}]

name

string

The DNS name this entry is for.

Returned: always

Sample: "www.example.com"

nameservers

list / elements=string

A list of nameservers for this DNS name.

Returned: success

Sample: ["ns1.example.com", "ns2.example.com"]

Authors

  • Felix Fontein (@felixfontein)