ansible.windows.win_dns_record_info module – Get Windows Server DNS records

Note

This module is part of the ansible.windows collection (version 3.9.1).

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 ansible.windows. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: ansible.windows.win_dns_record_info.

New in ansible.windows 3.10.0

Synopsis

  • List resource records in an existing Windows DNS zone or retrieve records by owner and type.

  • This module is read-only and supports check mode.

Requirements

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

  • The DnsServer PowerShell module on the execution host.

  • Permission to read the selected DNS server and zone.

Parameters

Parameter

Comments

computer_name

string

The DNS server to query. When omitted, use the execution host’s local server.

When using WinRM through another host, configure authentication that permits access to this server.

name

string

The record owner relative to zone, or its fully qualified name within that zone.

Use @ or the zone’s fully qualified name to query the zone apex.

When omitted, query all owners in the zone.

When no records match, records is empty and exists is false.

type

string

The resource record type accepted by the DNS server, such as A, AAAA, CNAME, SRV, or TXT.

When omitted, query all record types.

zone

string / required

The existing DNS zone to query.

A missing zone, access denial, or connection failure causes an error.

zone_scope

string

The existing zone scope to query.

When omitted, use the default scope.

See Also

See also

ansible.windows.win_dns_record

Manage Windows Server DNS records.

ansible.windows.win_dns_zone

Manage Windows Server DNS Zones.

Examples

- name: List records in a zone
  ansible.windows.win_dns_record_info:
    zone: example.com
  register: dns_records

- name: Get a host's IPv4 records from a selected server
  ansible.windows.win_dns_record_info:
    zone: example.com
    name: database.example.com
    type: A
    computer_name: dns.example.com
  register: database_records

Return Values

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

Key

Description

exists

boolean

Whether any records matched the query.

Returned: always

Sample: true

records

list / elements=dictionary

Matching records sorted by owner, type, and value.

Returned: always

aging

boolean

Whether the record has an aging timestamp.

Returned: success

Sample: false

data

dictionary

Type-specific provider fields with IP addresses converted to strings and arrays preserved.

Common fields use snake case, including ipv4_address, domain_name, port, priority, and weight.

Other provider field names are lowercased.

Returned: success

Sample: {"ipv4_address": "192.0.2.1"}

name

string

The owner relative to the zone.

Returned: success

Sample: "database"

record_values

list / elements=string

Primary record values as strings for A, AAAA, CNAME, DHCID, NS, PTR, SRV, TXT, and MX records.

TXT segments are joined into a single value. Other record types have an empty list; inspect records[].data.

Returned: success

Sample: ["192.0.2.1"]

timestamp

string

The provider timestamp in ISO 8601 format, or null for static records.

Returned: success

ttl

integer

The time to live in seconds.

Returned: success

Sample: 3600

type

string

The resource record type.

Returned: success

Sample: "A"

Authors

  • Ansible Project (@ansible)