]> git.phdru.name Git - ansible.git/blob - playbooks/debian/roles/add-dns-domain/tasks/main.yml
Refactor: Join tasks into blocks to factor out conditions
[ansible.git] / playbooks / debian / roles / add-dns-domain / tasks / main.yml
1 - name: Check domain
2   stat:
3     path: "/etc/bind/{{ domain }}"
4   register: domain_exists
5   changed_when: not domain_exists.stat.exists
6
7 - block:
8     - name: Copy domain template
9       become: true
10       template:
11         src: domain
12         dest: "/etc/bind/{{ domain }}"
13         owner: bind
14         group: bind
15         mode: '0600'
16         force: no
17
18     - name: Update config
19       become: true
20       shell: |
21         echo 'zone "{{ domain }}" {
22               type master;
23               file "/etc/bind/{{ domain }}";
24               allow-query { any; };
25               notify yes;
26         };' >> /etc/bind/named.conf.local
27
28
29     - name: Reload BIND
30       become: true
31       service:
32         name: bind9
33         state: reloaded
34   when: not domain_exists.stat.exists