Create a Windows DNS Zone With Ansible

In this blog post, I will show you how to create an Active Directory Primary Zone with Ansible for windows.

DNS

The reason Active Directory zones are very good is that they are replicating with Active Directory. When we set up a new Domain Controller the AD DNS zones are automatically replicating which reduces the need to manage DNS as a separate system.

PlayBook

Before we get into the playbook, it is important to note that I am going to use a 2.10 Ansible module for Windows DNS. The module can work with Ansible 2.9, but you will need to run the following like to download the module first.

ansible-galaxy collection install community.windows

If you have Ansible 2.10 install, you don’t need to worry about the above line. To upgrade to Ansible 2.10, check this post.

The Playbook below will create a DNS zone and will apply to hosts in the DCs host group.

- name: "DNS Zone"
  hosts: DCs
  tasks:
    - name: "Create a DNS Zone"
      community.windows.win_dns_zone:
         name: svc.corporate.local
         replication: domain
         type: primary
         state: present

For more Ansible on Windows posts visit the following page.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.