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

39 lines
945 B
YAML
Raw Normal View History

2021-08-17 00:11:04 +02:00
- name: Check if dnsmasq is setup
2022-04-15 15:51:58 +02:00
ansible.builtin.stat:
2021-08-17 00:11:04 +02:00
path: "/etc/dnsmasq.d/"
register: dnsmasq_setup
2020-10-28 22:15:23 +01:00
- name: Set up dnsmasq hosts
register: dnsmasq_hosts
2022-10-19 00:16:16 +02:00
become: "{{ do_become }}"
2020-10-28 22:15:23 +01:00
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
2022-10-19 00:16:16 +02:00
become: "{{ do_become }}"
2020-10-28 22:15:23 +01:00
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
2022-04-15 15:51:58 +02:00
ansible.builtin.stat:
2021-08-17 00:11:04 +02:00
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
2022-10-19 00:16:16 +02:00
become: "{{ do_become }}"
2020-10-28 22:15:23 +01:00
ansible.builtin.command:
argv:
- pihole
- restartdns