]> git.phdru.name Git - ansible.git/blob - playbooks/debian/roles/add-dns-domain/tasks/main.yml
e61fd3dcc33e2d89d6fce494ff0d3223f5d79aa6
[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 '
22         zone "{{ domain }}" {
23               type master;
24               file "/etc/bind/{{ domain }}";
25               allow-query { any; };
26               notify yes;
27         };' >> /etc/bind/named.conf.local
28
29
30     - name: Update resolver config
31       become: true
32       lineinfile:
33         path: /etc/resolv.conf
34         regexp: "^domain {{ domain }}"
35         line: "domain {{ domain }}"
36
37     - name: Reload BIND
38       become: true
39       service:
40         name: bind9
41         state: reloaded
42   when: not domain_exists.stat.exists