]> git.phdru.name Git - ansible.git/blobdiff - playbooks/roles/debian/named/tasks/main.yaml
Feat: Rename `*.yml` to `*.yaml`
[ansible.git] / playbooks / roles / debian / named / tasks / main.yaml
diff --git a/playbooks/roles/debian/named/tasks/main.yaml b/playbooks/roles/debian/named/tasks/main.yaml
new file mode 100644 (file)
index 0000000..9bc3d00
--- /dev/null
@@ -0,0 +1,46 @@
+- name: Check named.conf.options
+  become: true
+  shell: "grep -c '^\\s*allow-query' /etc/bind/named.conf.options || :"
+  register: named_conf
+  changed_when: named_conf.stdout in ('', "0")
+
+- debug:
+    msg: "BIND has already been configured"
+  when: named_conf.stdout not in ('', "0")
+
+- block:
+    - name: Install BIND
+      become: true
+      apt:
+        autoclean: yes
+        autoremove: yes
+        cache_valid_time: 3600
+        install_recommends: no
+        name: bind9
+        state: latest
+        update_cache: yes
+
+    - name: Configure BIND
+      become: true
+      template:
+        src: named.conf.options
+        dest: /etc/bind/named.conf.options
+        owner: bind
+        group: bind
+        mode: '0600'
+
+    - name: Reload BIND
+      become: true
+      service:
+        name: named
+        state: reloaded
+
+    - name: Configure resolver
+      become: true
+      copy:
+        content: "nameserver 127.0.0.1"
+        dest: /etc/resolv.conf
+        owner: root
+        group: root
+        mode: '0644'
+  when: named_conf.stdout in ('', "0")