Ansible Playbook for installing bind9 + domains
That is primarily my own set of instructions how to install bind9. But feel free to look around ...
- files/named.conf.local.template: template for bind9-data/named.conf.local, either use the template or create your own file
- files/named.conf.options.template: template for bind9-data/named.conf.options, either use the template or create your own file
- bind9-data/keys/: install any key files here, for communication with other nameservers - any file which ends on .key will be copied
- bind9-data/zones/: install any zone file here - any file which ends on .zone will be copied, and the zone_serial variable will he handled
- bind9-data/zone-data/: storage area for zone checksums and serials - do not touch
By default, all data for bind9 lives in the bind9-data directory in the root of the Playbook. This can be changed by modifying the bind9_data variable in vars/main.yml.
A few directories have to be created before this role can be used:
mkdir bind9-data
mkdir bind9-data/keys
mkdir bind9-data/zones
mkdir bind9-data/zone-data
chmod 0700 bind9-data
Installing the role will verify that certain directories exist locally (in $bind9_data), and will install and configure Bind 9 on the server.
It will not deploy the configuration and the zones.
- hosts: dns
become: yes
gather_facts: True
any_errors_fatal: True
force_handlers: True
vars:
bind9_data: "{{ playbook_dir }}/bind9-data"
roles:
- role: bind9
- hosts: dns
become: yes
gather_facts: True
any_errors_fatal: True
force_handlers: True
vars:
bind9_data: "{{ playbook_dir }}/bind9-data"
tasks:
- name: Deploy configuration and zones
include: roles/bind9/tasks/deploy.yml
handlers:
- include: roles/bind9/handlers/main.yml
You can handle the serial number in a zone as you like - if you include a variable {{ zone_serial }}, this variable will he handled by the Playbook.
Every time the zone is changed, the current date (yyyymmdd) and a two-digit counter will be set and increased. Date changes will reset the counter to "01", and after "99" changes a day the Playbook will reject any further changes.