win_dns_record – Manage Windows Server DNS records

New in version 2.8.

Synopsis

  • Manage DNS records within an existing Windows Server DNS zone.

Requirements

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

  • This module requires Windows 8, Server 2012, or newer.

Parameters

Parameter Choices/Defaults Comments
computer_name
string
Specifies a DNS server.
You can specify an IP address or any value that resolves to an IP address, such as a fully qualified domain name (FQDN), host name, or NETBIOS name.
name
string / required
The name of the record.
state
string
    Choices:
  • absent
  • present ←
Whether the record should exist or not.
ttl
integer
Default:
3600
The "time to live" of the record, in seconds.
Ignored when state=absent.
Valid range is 1 - 31557600.
Note that an Active Directory forest can specify a minimum TTL, and will dynamically "round up" other values to that minimum.
type
string / required
    Choices:
  • A
  • AAAA
  • CNAME
  • PTR
The type of DNS record to manage.
value
list
The value(s) to specify. Required when state=present.
When type=PTR only the partial part of the IP should be given.

aliases: values
zone
string / required
The name of the zone to manage (eg example.com).
The zone must already exist.

Examples

# Demonstrate creating a matching A and PTR record.

- name: Create database server record
  win_dns_record:
    name: "cgyl1404p.amer.example.com"
    type: "A"
    value: "10.1.1.1"
    zone: "amer.example.com"

- name: Create matching PTR record
  win_dns_record:
    name: "1.1.1"
    type: "PTR"
    value: "db1"
    zone: "10.in-addr.arpa"

# Demonstrate replacing an A record with a CNAME

- name: Remove static record
  win_dns_record:
    name: "db1"
    type: "A"
    state: absent
    zone: "amer.example.com"

- name: Create database server alias
  win_dns_record:
    name: "db1"
    type: "CNAME"
    value: "cgyl1404p.amer.example.com"
    zone: "amer.example.com"

# Demonstrate creating multiple A records for the same name

- name: Create multiple A record values for www
  win_dns_record:
    name: "www"
    type: "A"
    values:
      - 10.0.42.5
      - 10.0.42.6
      - 10.0.42.7
    zone: "example.com"

# Demonstrates a partial update (replace some existing values with new ones)
# for a pre-existing name

- name: Update www host with new addresses
  win_dns_record:
    name: "www"
    type: "A"
    values:
      - 10.0.42.5  # this old value was kept (others removed)
      - 10.0.42.12  # this new value was added
    zone: "example.com"

Status

Authors

  • John Nelson (@johnboy2)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.