Infra/ansible/roles/pi_dnsmasq/tasks/main.yml

39 lines
874 B
YAML
Raw Normal View History

2021-08-17 00:11:04 +02:00
- name: Check if dnsmasq is setup
stat:
path: "/etc/dnsmasq.d/"
register: dnsmasq_setup
2020-10-28 22:15:23 +01:00
- name: Set up dnsmasq hosts
register: dnsmasq_hosts
become: true
ansible.builtin.template:
src: hosts.custom.j2
group: root
owner: root
mode: 0644
dest: /etc/hosts.custom
- name: Set up dnsmasq rules
2021-08-17 00:11:04 +02:00
when: dnsmasq_setup.stat.isdir is defined and dnsmasq_setup.stat.isdir
2020-10-28 22:15:23 +01:00
register: dnsmasq
become: true
ansible.builtin.template:
src: 02-custom.conf.j2
group: root
owner: root
mode: 0644
dest: /etc/dnsmasq.d/02-custom.conf
2021-08-17 00:11:04 +02:00
- name: Check if PiHole is installed
stat:
path: "/usr/local/bin/pihole"
register: pihole_bin
2020-10-28 22:15:23 +01:00
- name: Restart PiHole systems
2021-08-17 00:11:04 +02:00
when: (dnsmasq.changed or dnsmasq_hosts.changed) and pihole_bin.stat.exists
2020-10-28 22:15:23 +01:00
become: true
ansible.builtin.command:
argv:
- pihole
- restartdns