X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=playbooks%2Fdebian%2Froles%2Fnamed%2Ftasks%2Fmain.yml;h=8c6b7d0f9e6048c1cb69f5ac2d3e7a5ce5aab59d;hb=9d43bd9e52701c477ba57d6a0275a6b259a183f8;hp=092d531340c158c69a7c23bbe276fc8216fe3e9c;hpb=f0661e4d80d614401d75e1a38eba3918315debdd;p=ansible.git diff --git a/playbooks/debian/roles/named/tasks/main.yml b/playbooks/debian/roles/named/tasks/main.yml index 092d531..8c6b7d0 100644 --- a/playbooks/debian/roles/named/tasks/main.yml +++ b/playbooks/debian/roles/named/tasks/main.yml @@ -1,37 +1,37 @@ - name: Check named.conf.options - shell: "grep -c '^[ \\t]\\+allow-query' /etc/bind/named.conf.options || echo 0" + become: true + shell: "grep -c '^\\s*allow-query' /etc/bind/named.conf.options || :" register: named_conf - changed_when: named_conf.stdout == "0" + changed_when: named_conf.stdout in ('', "0") - debug: msg: "BIND has already been configured" - when: named_conf.stdout != "0" + when: named_conf.stdout not in ('', "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" +- block: + - name: Install BIND + become: true + apt: + autoclean: yes + autoremove: yes + install_recommends: no + name: bind9 + purge: yes + state: latest + update_cache: yes -- 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: Configure BIND + become: true + copy: + src: named.conf.options + dest: /etc/bind/named.conf.options + owner: bind + group: bind + mode: '0600' -- name: Reload BIND - become: true - service: - name: bind9 - state: reloaded - when: named_conf.stdout == "0" + - name: Reload BIND + become: true + service: + name: bind9 + state: reloaded + when: named_conf.stdout in ('', "0")