- name: Check domain stat: path: "/etc/bind/{{ domain }}" register: domain_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 ' 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: Reload BIND become: true service: name: bind9 state: reloaded when: not domain_exists.stat.exists