]> git.phdru.name Git - ansible.git/blob - playbooks/debian/roles/add-dns-domain/tasks/main.yml
Feat: Add `changed_when`
[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 - name: Copy domain template
8   become: true
9   template:
10     src: domain
11     dest: "/etc/bind/{{ domain }}"
12     owner: bind
13     group: bind
14     mode: '0600'
15     force: no
16   when: not domain_exists.stat.exists
17
18 - name: Update config
19   become: true
20   shell: |
21     echo '
22
23     zone "{{ domain }}" {
24           type master;
25           file "/etc/bind/{{ domain }}";
26           allow-query { any; };
27           notify yes;
28     };' >> /etc/bind/named.conf.local
29
30
31   when: not domain_exists.stat.exists
32
33 - name: Reload BIND
34   become: true
35   service:
36     name: bind9
37     state: reloaded
38   when: not domain_exists.stat.exists