Infra/ansible/roles/pi_dnsmasq/tasks/main.yml
2022-10-19 00:17:37 +02:00

39 lines
945 B
YAML

- name: Check if dnsmasq is setup
ansible.builtin.stat:
path: "/etc/dnsmasq.d/"
register: dnsmasq_setup
- name: Set up dnsmasq hosts
register: dnsmasq_hosts
become: "{{ do_become }}"
ansible.builtin.template:
src: hosts.custom.j2
group: root
owner: root
mode: 0644
dest: /etc/hosts.custom
- name: Set up dnsmasq rules
when: dnsmasq_setup.stat.isdir is defined and dnsmasq_setup.stat.isdir
register: dnsmasq
become: "{{ do_become }}"
ansible.builtin.template:
src: 02-custom.conf.j2
group: root
owner: root
mode: 0644
dest: /etc/dnsmasq.d/02-custom.conf
- name: Check if PiHole is installed
ansible.builtin.stat:
path: "/usr/local/bin/pihole"
register: pihole_bin
- name: Restart PiHole systems
when: (dnsmasq.changed or dnsmasq_hosts.changed) and pihole_bin.stat.exists
become: "{{ do_become }}"
ansible.builtin.command:
argv:
- pihole
- restartdns