This is a role which installs two DNS servers. One primary DNS and one secondary slave with passed records from Ansible variables.
This module requires 3 hosts groups: dns
, bind-master
and bind-slave
:
- All DNS servers should belong under the
dns
group. - Any master DNS servers should belong under
bind-master
- Any slave DNS servers will refer to primary DNS in the
bind-master
group and they belong underbind-slave
[dns:children]
bind-master
bind-slave
[bind-master]
ns1.example.com
[bind-slave]
ns2.example.com
Here is an example variables file
---
bind:
dnssec: 'yes'
recursion: 'no'
admin_email: vagrant.edig.co.uk # Admin email for all zones
nameservers: # A list of nameserver name -> ip pairs
- name: ns1.example.co.uk.
ip: 172.16.10.14
- name: ns2.example.co.uk.
ip: 172.16.10.15
zones: # A dictionary of zones to create
example.co.uk:
records: # A dictionary of record types
a:
web: 172.16.10.13
10.16.172.in-addr.arpa: # A reverse zone for servers
records:
# PTR records - the key is the last octet of your server IP. For example ip is 172.16.10.15 the key would be 15
ptr:
13: web.example.co.uk.
14: ns1.example.co.uk.
15: ns2.example.co.uk.
forwarders:
example:
targets:
- ip: 127.0.0.1
port: 8600
The role will create the forward zone example.co.uk
with one A record web.example.co.uk
pointing to 172.16.10.13 in this case. It will also create the reverse zones so both servers can answer reverse lookups.
DNS forwarders can be created to forward queries to other DNS services and discovery tools. There are two types of forwarders
forwarders
- Forwards a specific DNS name to a NS serverroot_forwarders
- Forwards all queries to a given NS
This role provides three handlers
reload-bind
start-bind
restart-bind
- name: DNS | BIND Setup
hosts: dns
roles:
- edr.bind