2 - name: install unbound
3 apt: name=unbound state=latest
5 - name: configure unbound
6 register: unbound_config
8 dest: /etc/unbound/unbound.conf.d/listen.conf
10 - name: configure systemd (create dir)
11 file: path=/etc/systemd/system/unbound.service.d state=directory
12 - name: configure systemd (tweak unbound)
13 register: unbound_systemd
15 dest: /etc/systemd/system/unbound.service.d/override.conf
16 src: files/unbound.service.override
17 - name: reload systemd
18 when: unbound_systemd.changed
19 command: systemctl daemon-reload
20 - name: restart unbound
21 # not a handler to make sure it succeeds before we go touch system DNS
22 when: unbound_config.changed
23 service: name=unbound state=restarted enabled=yes
25 - name: detect DHCP client
26 stat: path=/etc/dhcp/dhclient.conf
28 - name: configure DHCP
29 when: dhclient.stat.exists == True
31 dest: /etc/dhcp/dhclient.conf
32 src: files/dhclient.conf
33 - name: configure system DNS
36 content: "nameserver 127.0.0.2\noptions trust-ad\noptions edns0\n"
38 - /etc/resolv.conf.unbound
40 # some providers need extra hacks to make our DNS persistent
41 - name: install DNS-fix cronjob
43 dest: /etc/cron.hourly/fix-dns
44 src: templates/fix-dns