]> git.phdru.name Git - ansible.git/blob - playbooks/debian/roles/add-dns-domain/tasks/main.yml
Feat(add-dns-domain): Add the domain to `/etc/resolv.conf`
[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: Update resolver config
30       become: true
31       lineinfile:
32         path: /etc/resolv.conf
33         regexp: "^domain {{ domain }}"
34         line: "domain {{ domain }}"
35
36     - name: Reload BIND
37       become: true
38       service:
39         name: bind9
40         state: reloaded
41   when: not domain_exists.stat.exists