]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-cm-ansible.git/commitdiff
nameserver: Add configuration task for named service
authorDavid Galloway <dgallowa@redhat.com>
Wed, 20 Apr 2016 23:54:46 +0000 (19:54 -0400)
committerDavid Galloway <dgallowa@redhat.com>
Fri, 22 Apr 2016 16:37:47 +0000 (12:37 -0400)
Signed-off-by: David Galloway <dgallowa@redhat.com>
roles/nameserver/defaults/main.yml
roles/nameserver/tasks/config.yml [new file with mode: 0644]
roles/nameserver/tasks/main.yml
roles/nameserver/templates/named.conf.j2 [new file with mode: 0644]

index 37cdbdb03f8315295b5cd6a0b117750ea004deb0..9713692f28494688ebe6713f5d9603599d5a7460 100644 (file)
@@ -7,6 +7,13 @@ secrets_repo:
   url: null
 
 # Main BIND conf vars
+named_conf_dir: "/var/named"
+named_conf_file: "/etc/named.conf"
+named_conf_data_dir: "/var/named/data"
+named_conf_listen_port: 53
+named_conf_listen_iface:
+ - 127.0.0.1
+ - "{{ ansible_all_ipv4_addresses[0] }}"
 named_conf_zones_path: "/var/named/zones"
 
 # Zone file conf vars
diff --git a/roles/nameserver/tasks/config.yml b/roles/nameserver/tasks/config.yml
new file mode 100644 (file)
index 0000000..0899d96
--- /dev/null
@@ -0,0 +1,13 @@
+---
+- name: Create named data directory
+  file:
+    path: "{{ named_conf_data_dir }}"
+    state: directory
+
+- name: Create named.conf
+  template:
+    src: named.conf.j2
+    dest: "{{ named_conf_file }}"
+    validate: named-checkconf %s
+  notify: restart named
+  with_dict: "{{ named_domains }}"
index 5dcc629cb5edca9caec144ba86afeca0e4b449eb..f487ee37437fb1efdd56ed51d97e1dc6a0a17320 100644 (file)
@@ -4,6 +4,11 @@
   tags:
     - packages
 
+# Configure BIND
+- include: config.yml
+  tags:
+    - config
+
 # Compile and write zone files
 - include: records.yml
   tags:
diff --git a/roles/nameserver/templates/named.conf.j2 b/roles/nameserver/templates/named.conf.j2
new file mode 100644 (file)
index 0000000..04c83cb
--- /dev/null
@@ -0,0 +1,46 @@
+#
+# {{ ansible_managed }}
+#
+
+options {
+       listen-on port {{ named_conf_listen_port }} { {% for interface in named_conf_listen_iface -%}{{ interface }}; {% endfor -%} };
+
+       directory               "{{ named_conf_dir }}";
+       dump-file               "{{ named_conf_data_dir }}/cache_dump.db";
+       statistics-file         "{{ named_conf_data_dir }}/named_stats.txt";
+       memstatistics-file      "{{ named_conf_data_dir }}/named_mem_stats.txt";
+
+       allow-query             { any; };
+       recursion               yes;
+       allow-recursion         { any; };
+};
+
+logging {
+       channel                 default_debug {
+       file                    "{{ named_conf_data_dir }}/named.run";
+       severity                dynamic;
+        };
+};
+
+# Forward zones
+{% for key, zone in named_domains.iteritems() %}
+zone "{{ key }}" {
+       type    master;
+       file    "{{ named_conf_zones_path }}/{{ key }}";
+};
+
+{% endfor %}
+
+# Reverse zones
+{% for key, zone in named_domains.iteritems() %}
+{% if zone.reverse is defined and zone.reverse.0 is defined %}
+{% for reverse in zone.reverse %}
+{% set octet1,octet2,octet3 = reverse.split('.') %}
+zone "{{ octet3 }}.{{ octet2 }}.{{ octet1 }}.in-addr.arpa" {
+       type    master;
+       file    "{{ named_conf_zones_path }}/{{ reverse }}";
+};
+
+{% endfor %}
+{% endif %}
+{% endfor %}