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=8837d99520ad463e1c431e9506b0cb0d3aeb3051;hpb=ee8aa3427d674d56e57c034f270388745ed72582;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 8837d99..cf5e1d2 100644 --- a/playbooks/debian/roles/add-dns-domain/tasks/main.yml +++ b/playbooks/debian/roles/add-dns-domain/tasks/main.yml @@ -2,37 +2,41 @@ stat: path: "/etc/bind/{{ domain }}" 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