diff --git a/files/masters/db.example.com b/files/masters/db.example.com index a534853..0cee92b 100644 --- a/files/masters/db.example.com +++ b/files/masters/db.example.com @@ -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. ( diff --git a/files/named.conf b/files/named.conf index eef8b96..eec9bd5 100644 --- a/files/named.conf +++ b/files/named.conf @@ -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 @@ -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"; diff --git a/files/named.conf.default-zones b/files/named.conf.default-zones new file mode 100644 index 0000000..c508a76 --- /dev/null +++ b/files/named.conf.default-zones @@ -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"; +}; \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index 50b442c..65788f8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 }}" diff --git a/templates/named.conf.local.master.j2 b/templates/named.conf.local.master.j2 index fb26b21..215a44b 100644 --- a/templates/named.conf.local.master.j2 +++ b/templates/named.conf.local.master.j2 @@ -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 %} diff --git a/templates/named.conf.local.slave.j2 b/templates/named.conf.local.slave.j2 index e20bad3..f0b1c1b 100644 --- a/templates/named.conf.local.slave.j2 +++ b/templates/named.conf.local.slave.j2 @@ -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 }};