Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

zone location #24

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions files/masters/db.example.com
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// !!!! Don't modify: this file was generated by Ansible !!!!

$TTL 4h
$ORIGIN example.com.
@ IN SOA ns1.example.com. hostmaster.example.com. (
Expand Down
34 changes: 3 additions & 31 deletions files/named.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// !!!! Don't modify: this file was generated by Ansible !!!!

// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian.gz for information on the
Expand All @@ -7,37 +9,7 @@
// If you are just adding zones, please do that in /etc/bind/named.conf.local

include "/etc/bind/named.conf.options";

// prime the server with knowledge of the root servers
zone "." {
type hint;
file "/etc/bind/db.root";
};

// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912

zone "localhost" {
type master;
file "/etc/bind/db.local";
};

zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};

zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};

zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};

include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.local.master";
include "/etc/bind/named.conf.local.slave";
include "/etc/bind/named.conf.local.forward";
include "/etc/bind/named.conf.default-zones";
30 changes: 30 additions & 0 deletions files/named.conf.default-zones
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// !!!! Don't modify: this file was generated by Ansible !!!!

// prime the server with knowledge of the root servers
zone "." {
type hint;
file "/etc/bind/db.root";
};

// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912

zone "localhost" {
type master;
file "/etc/bind/db.local";
};

zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};

zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};

zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};
18 changes: 11 additions & 7 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,36 @@
with_items: "{{ bind_pkgs }}"

- name: setup zone directories
file: dest={{ bind_base_zones_path }}/{{ item }} state=directory owner={{ bind_user }} group={{ bind_group }} mode=0755
file: dest="{{ bind_base_zones_path }}/{{ item }}" state=directory owner="{{ bind_user }}" group="{{ bind_group }}" mode=0755
with_items:
- masters
- slaves

- name: setup zones
template: src=named.conf.local.{{ item }}.j2 dest={{ bind_config_basepath }}/named.conf.local.{{ item }} owner={{ bind_user }} group={{ bind_group }} mode=0600
template: src="named.conf.local.{{ item }}.j2" dest="{{ bind_config_basepath }}/named.conf.local.{{ item }}" owner="{{ bind_user }}" group="{{ bind_group }}" mode=0600
with_items:
- master
- slave
- forward
notify: reload bind

- name: configure bind
copy: src=named.conf dest={{ bind_config_basepath }}/named.conf owner={{ bind_user }} group={{ bind_group }} mode=0600
- name: configure bind (named.conf)
copy: src=named.conf dest="{{ bind_config_basepath }}/named.conf" owner="{{ bind_user }}" group="{{ bind_group }}" mode=0600
notify: restart bind

- name: configure bind (named.conf.default-zones)
copy: src=named.conf.default-zones dest="{{ bind_config_basepath }}/named.conf.default-zones" owner="{{ bind_user }}" group="{{ bind_group }}" mode=0600
notify: restart bind

- name: configure bind options
template: src=named.conf.options.j2 dest={{ bind_config_basepath }}/named.conf.options owner={{ bind_user }} group={{ bind_group }} mode=0600
template: src=named.conf.options.j2 dest="{{ bind_config_basepath }}/named.conf.options" owner="{{ bind_user }}" group="{{ bind_group }}" mode=0600
notify: restart bind

- name: Copy master zone files
copy: src={{ bind_masterzones_path }}/db.{{ item.name }} dest={{ bind_base_zones_path }}/{{bind_masterzones_path}} owner={{ bind_user }} group={{ bind_group }}
copy: src="{{ bind_masterzones_path }}/db.{{ item.name }}" dest="{{ bind_base_zones_path }}/masters/db.{{ item.name }}" owner="{{ bind_user }}" group="{{ bind_group }}"
with_items: "{{ bind_config_master_zones }}"
notify: reload bind
tags: bind-zones

- name: start/stop bind service
service: name={{ bind_service_name }} state={{ bind_service_state }} enabled={{ bind_service_enabled }}
service: name="{{ bind_service_name }}" state="{{ bind_service_state }}" enabled="{{ bind_service_enabled }}"
2 changes: 1 addition & 1 deletion templates/named.conf.local.master.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% for master_zone in bind_config_master_zones %}
zone "{{ master_zone.name }}" {
type master;
file "{{bind_base_zones_path}}/{{bind_masterzones_path}}/db.{{ master_zone.name }}";
file "{{bind_base_zones_path}}/masters/db.{{ master_zone.name }}";
{% if master_zone.allow_transfer is defined %}
allow-transfer {
{% for allow_transfer in master_zone.allow_transfer %}
Expand Down
2 changes: 1 addition & 1 deletion templates/named.conf.local.slave.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% for zone in slave_zone.zones %}
zone "{{ zone }}" {
type slave;
file "{{bind_base_zones_path}}/{{bind_slavezones_path}}/db.{{ zone }}";
file "{{bind_base_zones_path}}/slaves/db.{{ zone }}";
masters {
{% for master in slave_zone.masters %}
{{ master }};
Expand Down