From c4ea346f89a2358e553d95ddd0a7399199b29998 Mon Sep 17 00:00:00 2001 From: krahser Date: Tue, 28 Apr 2015 14:20:20 -0300 Subject: [PATCH 1/3] The validation runs before copying into place. https://github.com/resmo/ansible-role-bind/commit/cf5b84104db90703764dcf6edb90d06a18bd3598 There is a new play after copy files called check files. This new play verify named.conf and named.conf.options with the command named-checkconf --- tasks/main.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 97bef9f..ef0fa4c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -21,15 +21,21 @@ tags: configuration - name: configure bind - copy: src=named.conf dest={{ bind_config_basepath }}/named.conf owner={{ bind_user }} group={{ bind_group }} mode=0600 validate='named-checkconf %s' - notify: restart bind + copy: src=named.conf dest={{ bind_config_basepath }}/named.conf owner={{ bind_user }} group={{ bind_group }} mode=0600 tags: configuration - 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 validate='named-checkconf %s' - notify: restart bind + template: src=named.conf.options.j2 dest={{ bind_config_basepath }}/named.conf.options owner={{ bind_user }} group={{ bind_group }} mode=0600 tags: configuration +- name: check files + command: named-checkconf "{{ bind_config_basepath }}/{{ item}}" + with_items: + - named.conf + - named.conf.options + 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 }} with_items: bind_config_master_zones From c0662e049434704631aa0a4f3267ddd770c10241 Mon Sep 17 00:00:00 2001 From: krahser Date: Tue, 28 Apr 2015 14:41:16 -0300 Subject: [PATCH 2/3] notify and recursion configuration notify could be explicit and specific per zone recursion is a boolean configuration that could be fine-grained control with the allow-recursion statement. http://www.zytrax.com/books/dns/ch7/queries.html#recursion --- templates/named.conf.options.j2 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/templates/named.conf.options.j2 b/templates/named.conf.options.j2 index d62a30c..d9d4788 100644 --- a/templates/named.conf.options.j2 +++ b/templates/named.conf.options.j2 @@ -23,11 +23,6 @@ options { {% endfor %} }; - notify yes; - - also-notify { - }; - //provide-ixfr no ; {% if bind_config_master_forwarders %} @@ -49,6 +44,15 @@ options { listen-on-v6 { any; }; allow-query { any; }; // This is the default - recursion {{ bind_config_recursion }}; // Do not provide recursive service + + {% if bind_config_recursion %} + // If you want to limit whose can use the recursion method. + + allow-recursion { + {% for network in bind_config_recursion %} + {{ network }}; + {% endfor %} + }; + {% endif %} zone-statistics yes; }; From d041c42a69f841429aee524c03631912b2650e21 Mon Sep 17 00:00:00 2001 From: krahser Date: Tue, 28 Apr 2015 14:51:13 -0300 Subject: [PATCH 3/3] Add options to setup notify and allow-query --- templates/named.conf.local.master.j2 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/templates/named.conf.local.master.j2 b/templates/named.conf.local.master.j2 index fb26b21..29d5cfb 100644 --- a/templates/named.conf.local.master.j2 +++ b/templates/named.conf.local.master.j2 @@ -4,6 +4,13 @@ zone "{{ master_zone.name }}" { type master; file "{{bind_base_zones_path}}/{{bind_masterzones_path}}/db.{{ master_zone.name }}"; +{% if master_zone.allow_query is defined %} + allow-query { +{% for allow_query in master_zone.allow_query %} + {{ allow_query }}; +{% endfor %} + }; +{% endif %} {% if master_zone.allow_transfer is defined %} allow-transfer { {% for allow_transfer in master_zone.allow_transfer %} @@ -18,6 +25,22 @@ zone "{{ master_zone.name }}" { {% endfor %} }; {% endif %} + +{% if master_zone.slave is defined or bind_config_master_allow_transfer is defined %} + notify explicit; + also-notify { +{% if bind_config_master_allow_transfer is defined %} +{% for notify_update in bind_config_master_allow_transfer %} + {{ notify_update }}; +{% endfor %} +{% endif %} +{% if master_zone.slave is defined %} +{% for notify_update in master_zone.slave %} + {{ notify_update }}; +{% endfor %} +{% endif %} + }; +{% endif %} }; {% endfor %}