ansible.windows.win_dns_zone module – Manage Windows Server DNS Zones
Note
This module is part of the ansible.windows collection (version 2.5.0).
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_zone
.
New in ansible.windows 2.6.0
Synopsis
Manage Windows Server DNS Zones
Adds, Removes and Modifies DNS Zones - Primary, Secondary, Forwarder & Stub
Task should be delegated to a Windows DNS Server
Requirements
The below requirements are needed on the host that executes this module.
This module requires Windows Server 2012R2 or Newer
Parameters
Parameter |
Comments |
---|---|
Specifies an list of IP addresses of the primary servers of the zone. DNS queries for a forwarded zone are sent to primary servers. Required if l(type=secondary), l(type=forwarder) or l(type=stub), otherwise ignored. At least one server is required. |
|
Specifies how a zone handles dynamic updates. Secure DNS updates are available only for Active Directory-integrated zones. When not specified during new zone creation, Windows will default this to l(none). Choices:
|
|
Specifies a length of time, in seconds, that a DNS server waits for a remote DNS server to resolve a query. Accepts integer values between 0 and 15. If the provided value is not valid, it will be omitted and a warning will be issued. |
|
Fully qualified name of the DNS zone. |
|
Specifies the replication scope for the DNS zone. l(replication=forest) will replicate the DNS zone to all domain controllers in the Active Directory forest. l(replication=domain) will replicate the DNS zone to all domain controllers in the Active Directory domain. l(replication=none) disables Active Directory integration and creates a local file with the name of the zone. This is the equivalent of selecting l(store the zone in Active Directory) in the GUI. Choices:
|
|
Specifies the desired state of the DNS zone. When l(state=present) the module will attempt to create the specified DNS zone if it does not already exist. When l(state=absent), the module will remove the specified DNS zone and all subsequent DNS records. Choices:
|
|
Specifies the type of DNS zone. When l(type=secondary), the DNS server will immediately attempt to perform a zone transfer from the servers in this list. If this initial transfer fails, then the zone will be left in an unworkable state. This module does not verify the initial transfer. Choices:
|
Examples
- name: Ensure primary zone is present
ansible.windows.win_dns_zone:
name: wpinner.euc.vmware.com
replication: domain
type: primary
state: present
- name: Ensure DNS zone is absent
ansible.windows.win_dns_zone:
name: jamals.euc.vmware.com
state: absent
- name: Ensure forwarder has specific DNS servers
ansible.windows.win_dns_zone:
name: jamals.euc.vmware.com
type: forwarder
dns_servers:
- 10.245.51.100
- 10.245.51.101
- 10.245.51.102
- name: Ensure stub zone has specific DNS servers
ansible.windows.win_dns_zone:
name: virajp.euc.vmware.com
type: stub
dns_servers:
- 10.58.2.100
- 10.58.2.101
- name: Ensure stub zone is converted to a secondary zone
ansible.windows.win_dns_zone:
name: virajp.euc.vmware.com
type: secondary
- name: Ensure secondary zone is present with no replication
ansible.windows.win_dns_zone:
name: dgemzer.euc.vmware.com
type: secondary
replication: none
dns_servers:
- 10.19.20.1
- name: Ensure secondary zone is converted to a primary zone
ansible.windows.win_dns_zone:
name: dgemzer.euc.vmware.com
type: primary
replication: none
dns_servers:
- 10.19.20.1
- name: Ensure primary DNS zone is present without replication
ansible.windows.win_dns_zone:
name: basavaraju.euc.vmware.com
replication: none
type: primary
- name: Ensure primary DNS zone has nonsecureandsecure dynamic updates enabled
ansible.windows.win_dns_zone:
name: basavaraju.euc.vmware.com
replication: none
dynamic_update: nonsecureandsecure
type: primary
- name: Ensure DNS zone is absent
ansible.windows.win_dns_zone:
name: marshallb.euc.vmware.com
state: absent
- name: Ensure DNS zones are absent
ansible.windows.win_dns_zone:
name: "{{ item }}"
state: absent
loop:
- jamals.euc.vmware.com
- dgemzer.euc.vmware.com
- wpinner.euc.vmware.com
- marshallb.euc.vmware.com
- basavaraju.euc.vmware.com
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
New/Updated DNS zone parameters Returned: When l(state=present) Sample: |