prole/infrastructure/playbooks/sync_pihole_toml.yml

38 lines
1.0 KiB
YAML

---
- name: Fetch gold Pi-hole config from pi.prole.org
hosts: pi.prole.org
become: true
gather_facts: false
tasks:
- name: Fetch /etc/pihole/pihole.toml to control node
ansible.builtin.fetch:
src: /etc/pihole/pihole.toml
dest: /tmp/pihole.toml.gold
flat: true
# - name: Show diff between current and gold
# ansible.builtin.command: diff -u /etc/pihole/pihole.toml /tmp/pihole.toml.gold
# register: toml_diff
# failed_when: false
# changed_when: false
- name: Apply gold Pi-hole config to raspberry.prole.org
hosts: raspberry.prole.org
become: true
gather_facts: false
tasks:
- name: Copy gold pihole.toml to raspberry
ansible.builtin.copy:
src: /tmp/pihole.toml.gold
dest: /etc/pihole/pihole.toml
owner: root
group: root
mode: "0644"
register: toml_copy
- name: Restart Pi-hole FTL if config changed
ansible.builtin.systemd:
name: pihole-FTL
state: restarted
when: toml_copy.changed