]> git.phdru.name Git - ansible.git/blob - playbooks/debian/roles/add-dns-domain/tasks/main.yml
Feat: Add role to add a DNS domain to named
[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
6 - name: Copy domain template
7   become: true
8   template:
9     src: domain
10     dest: "/etc/bind/{{ domain }}"
11     owner: bind
12     group: bind
13     mode: '0600'
14     force: no
15   when: not domain_exists.stat.exists
16
17 - name: Update config
18   become: true
19   shell: |
20 echo '
21
22 zone "{{ domain }}" {
23       type master;
24       file "/etc/bind/{{ domain }}";
25       allow-query { any; };
26       notify yes;
27 };
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