]> git.phdru.name Git - ansible.git/blobdiff - playbooks/debian/roles/named/tasks/main.yml
Feat: Add role `named` to setup `BIND 9`
[ansible.git] / playbooks / debian / roles / named / tasks / main.yml
diff --git a/playbooks/debian/roles/named/tasks/main.yml b/playbooks/debian/roles/named/tasks/main.yml
new file mode 100644 (file)
index 0000000..ded1b35
--- /dev/null
@@ -0,0 +1,37 @@
+- name: Check locales
+  shell: "grep -c '^[ \\t]\\+allow-query' /etc/bind/named.conf.options || :"
+  register: named_conf
+  changed_when: named_conf.stdout == "0"
+
+- debug:
+    msg: "BIND has already been configured"
+  when: named_conf.stdout != "0"
+
+- name: Install BIND
+  become: true
+  apt:
+    autoclean: yes
+    autoremove: yes
+    install_recommends: no
+    name: bind9
+    purge: yes
+    state: latest
+    update_cache: yes
+  when: named_conf.stdout == "0"
+
+- name: Configure BIND
+  become: true
+  copy:
+    src: named.conf.options
+    dest: /etc/bind/named.conf.options
+    owner: bind
+    group: bind
+    mode: '0600'
+  when: named_conf.stdout == "0"
+
+- name: Reload BIND
+  become: true
+  service:
+    name: bind9
+    state: reloaded
+  when: named_conf.stdout == "0"