ansible.windows.win_dns_record module – Manage 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.
New in ansible.windows 2.6.0
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 |
Comments |
|---|---|
Should aging be activated for the record. If set to Choices:
|
|
Specifies if any authenticated user can update the record. Applies when creating a record. Changing this option does not modify permissions on an existing record. If set to If set to For non-SRV records, this was previously hardcoded to Choices:
|
|
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. The execution host requires the When using WinRM through another host, configure authentication that permits access to the DNS server. |
|
The port number of the record. Required when Supported only for Valid range is 0 - 65535. |
|
The priority number for each service in SRV record. Required when Supported only for Valid range is 0 - 65535. |
|
Whether the record should exist or not. Choices:
|
|
The “time to live” of the record, in seconds. Ignored when Valid range is 1 - 31557600. Default: |
|
The type of DNS record to manage.
Choices:
|
|
The value(s) to specify. Required when For Multiple values can be supplied for record types that permit multiple records at the same owner. Default: |
|
Weightage given to each service record in SRV record. Required when Supported only for Valid range is 0 - 65535. |
|
The name of the zone to manage (eg The zone must already exist. |
|
The name of the zone scope to manage (eg The zone must already exist. |
See Also
See also
- ansible.windows.win_dns_record_info
Get Windows Server DNS records.
- ansible.windows.win_dns_zone
Manage Windows Server DNS Zones.
Examples
# Demonstrate creating a matching A and PTR record.
- name: Create database server record
ansible.windows.win_dns_record:
name: "cgyl1404p"
type: "A"
value: "10.1.1.1"
zone: "amer.example.com"
- name: Create matching PTR record
ansible.windows.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
ansible.windows.win_dns_record:
name: "db1"
type: "A"
state: absent
zone: "amer.example.com"
- name: Create database server alias
ansible.windows.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
ansible.windows.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
ansible.windows.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"
# Demonstrate creating a SRV record
- name: Creating a SRV record with port number and priority
ansible.windows.win_dns_record:
name: "test"
priority: 5
port: 995
state: present
type: "SRV"
weight: 2
value: "amer.example.com"
zone: "example.com"
# Demonstrate creating a NS record with multiple values
- name: Creating NS record
ansible.windows.win_dns_record:
name: "ansible.prog"
state: present
type: "NS"
values:
- ns1.example.com
- ns2.example.com
zone: "example.com"
# Demonstrate creating a TXT record
- name: Creating a TXT record with descriptive Text
ansible.windows.win_dns_record:
name: "test"
state: present
type: "TXT"
value: "justavalue"
zone: "example.com"
# Demostrate creating a A record to Zone Scope
- name: Create database server record
ansible.windows.win_dns_record:
name: "cgyl1404p"
type: "A"
value: "10.1.1.1"
zone: "amer.example.com"
zone_scope: "external"