]> git.phdru.name Git - ansible.git/blobdiff - playbooks/debian/roles/add-dns-domain/tasks/main.yml
Feat: Improve task names
[ansible.git] / playbooks / debian / roles / add-dns-domain / tasks / main.yml
index 88a49c227ed2752ac0cb12356cad16284bcf69bd..cf5e1d2af188f53716fd3a806cfbbdb0b9a6319c 100644 (file)
@@ -4,33 +4,39 @@
   register: domain_exists
   changed_when: not domain_exists.stat.exists
 
-- name: Copy domain template
-  become: true
-  template:
-    src: domain
-    dest: "/etc/bind/{{ domain }}"
-    owner: bind
-    group: bind
-    mode: '0600'
-    force: no
-  when: not domain_exists.stat.exists
+- block:
+    - name: Copy domain template
+      become: true
+      template:
+        src: domain
+        dest: "/etc/bind/{{ domain }}"
+        owner: bind
+        group: bind
+        mode: '0600'
+        force: no
 
-- name: Update config
-  become: true
-  shell: |
-    echo 'zone "{{ domain }}" {
-          type master;
-          file "/etc/bind/{{ domain }}";
-          allow-query { any; };
-          notify yes;
-    };' >> /etc/bind/named.conf.local
+    - name: Update domain config
+      become: true
+      shell: |
+        echo '
+        zone "{{ domain }}" {
+              type master;
+              file "/etc/bind/{{ domain }}";
+              allow-query { any; };
+              notify yes;
+        };' >> /etc/bind/named.conf.local
 
 
-  when: not domain_exists.stat.exists
+    - name: Update resolver config
+      become: true
+      lineinfile:
+        path: /etc/resolv.conf
+        regexp: "^domain {{ domain }}"
+        line: "domain {{ domain }}"
 
-- name: Reload BIND
-  become: true
-  service:
-    name: bind9
-    state: reloaded
+    - name: Reload BIND
+      become: true
+      service:
+        name: bind9
+        state: reloaded
   when: not domain_exists.stat.exists