X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=playbooks%2Fdebian%2Froles%2Fadd-dns-domain%2Ftasks%2Fmain.yml;h=cf5e1d2af188f53716fd3a806cfbbdb0b9a6319c;hb=26d81517d2d679920a82ba54a48c86e1aee38cdc;hp=80f3a6a7b8fdcbbe61ebca5b2faa3be0d7e3e7e4;hpb=6d82309ce9774f0e8e31947186740cdaccea6ecc;p=ansible.git diff --git a/playbooks/debian/roles/add-dns-domain/tasks/main.yml b/playbooks/debian/roles/add-dns-domain/tasks/main.yml index 80f3a6a..cf5e1d2 100644 --- a/playbooks/debian/roles/add-dns-domain/tasks/main.yml +++ b/playbooks/debian/roles/add-dns-domain/tasks/main.yml @@ -4,35 +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 - -- name: Update config - become: true - shell: | - echo ' +- block: + - name: Copy domain template + become: true + template: + src: domain + dest: "/etc/bind/{{ domain }}" + owner: bind + group: bind + mode: '0600' + force: no - 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