From e1d3d5ff7cb87cf10f364201369caa8f48f47a27 Mon Sep 17 00:00:00 2001 From: Maga Abdurakhmanov Date: Tue, 20 Dec 2016 01:47:48 +0300 Subject: [PATCH 1/5] * quote vars --- tasks/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index e45442f..dfb2d46 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: install bind packages apt: pkg={{ item }} state={{ bind_pkg_state }} - with_items: bind_pkgs + 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 @@ -27,7 +27,7 @@ - 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 }} - with_items: bind_config_master_zones + with_items: "{{bind_config_master_zones}}" notify: reload bind tags: bind-zones From f2638e7a91bb181e22f727d810d2b3c717260e60 Mon Sep 17 00:00:00 2001 From: Maga Abdurakhmanov Date: Tue, 20 Dec 2016 02:36:08 +0300 Subject: [PATCH 2/5] * quotes fixed --- tasks/main.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index dfb2d46..433c334 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -4,13 +4,13 @@ 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 @@ -18,18 +18,26 @@ notify: reload bind - name: configure bind - copy: src=named.conf dest={{ bind_config_basepath }}/named.conf owner={{ bind_user }} group={{ bind_group }} mode=0600 + copy: src=named.conf dest="{{ bind_config_basepath }}/named.conf" 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: Create directory for master zone files + file: + path: "{{ bind_base_zones_path }}/{{ bind_masterzones_path }}" + mode: 0760 + state: directory + owner: "{{ bind_user }}" + group: "{{ bind_group }}" + - 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 }} - with_items: "{{bind_config_master_zones}}" + copy: src="{{ bind_masterzones_path }}/db.{{ item.name }}" dest="{{ bind_base_zones_path }}/{{ bind_masterzones_path }}/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 }}" From 01adcec8c8f96270a9844cf2cb6f8a54accb66bf Mon Sep 17 00:00:00 2001 From: Maga Abdurakhmanov Date: Thu, 9 Feb 2017 23:50:19 +0100 Subject: [PATCH 3/5] * default zones moved to separate file --- files/masters/db.example.com | 2 ++ files/named.conf | 33 +++------------------------------ files/named.conf.default-zones | 30 ++++++++++++++++++++++++++++++ tasks/main.yml | 6 +++++- 4 files changed, 40 insertions(+), 31 deletions(-) create mode 100644 files/named.conf.default-zones 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..3caee86 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,8 @@ // 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 433c334..b284a3b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -17,10 +17,14 @@ - forward notify: reload bind -- name: configure bind +- 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 notify: restart bind From e8b90be844dc297651dca2f7c61d005e26fcacff Mon Sep 17 00:00:00 2001 From: Maga Abdurakhmanov Date: Fri, 10 Feb 2017 00:09:09 +0100 Subject: [PATCH 4/5] - .local file --- files/named.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/files/named.conf b/files/named.conf index 3caee86..eec9bd5 100644 --- a/files/named.conf +++ b/files/named.conf @@ -9,7 +9,6 @@ // If you are just adding zones, please do that in /etc/bind/named.conf.local include "/etc/bind/named.conf.options"; -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"; From c6b32eacb3d702ce9f783d1ebe3fe35ece834cb9 Mon Sep 17 00:00:00 2001 From: Maga Abdurakhmanov Date: Fri, 29 Sep 2017 05:47:31 +0200 Subject: [PATCH 5/5] * zone files location fixed --- tasks/main.yml | 10 +--------- templates/named.conf.local.master.j2 | 2 +- templates/named.conf.local.slave.j2 | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index b284a3b..da47734 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -29,16 +29,8 @@ 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: Create directory for master zone files - file: - path: "{{ bind_base_zones_path }}/{{ bind_masterzones_path }}" - mode: 0760 - state: directory - owner: "{{ bind_user }}" - group: "{{ bind_group }}" - - name: Copy master zone files - copy: src="{{ bind_masterzones_path }}/db.{{ item.name }}" dest="{{ bind_base_zones_path }}/{{ bind_masterzones_path }}/db.{{ item.name }}" 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 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 }};