2022-11-18 18:33:37 +01:00
|
|
|
---
|
|
|
|
# tasks file for pi-hole
|
|
|
|
|
2023-01-13 18:01:41 +01:00
|
|
|
- name: pi-hole role; setup the target as DNS server with Pi-Hole
|
2023-01-11 17:44:16 +01:00
|
|
|
when: "'global.update_only' not in ansible_run_tags"
|
2022-11-18 18:33:37 +01:00
|
|
|
block:
|
|
|
|
- name: Populate service facts
|
|
|
|
ansible.builtin.service_facts:
|
|
|
|
|
|
|
|
- name: Start install process for pihole if service not found
|
|
|
|
when: "ansible_facts.services['pihole-FTL.service'] is not defined"
|
|
|
|
block:
|
|
|
|
- name: Install cURL if not present
|
|
|
|
ansible.builtin.package:
|
|
|
|
name: curl
|
|
|
|
|
2022-11-19 11:48:56 +01:00
|
|
|
- name: Execute manually the automated install and follow instructions, after that you can install custom list
|
2022-11-18 18:33:37 +01:00
|
|
|
ansible.builtin.debug:
|
|
|
|
msg: "curl -sSL https://install.pi-hole.net | bash"
|
2022-11-19 11:48:56 +01:00
|
|
|
|
2022-11-21 16:52:36 +01:00
|
|
|
- name: iptables-webserver
|
|
|
|
ansible.builtin.include_role:
|
|
|
|
name: iptables-webserver
|
|
|
|
|
|
|
|
- name: iptables-persistent
|
|
|
|
ansible.builtin.include_role:
|
|
|
|
name: iptables-persistent
|
2023-01-11 17:44:16 +01:00
|
|
|
|
|
|
|
- name: Update pihole FTL
|
|
|
|
when: "'global.update_only' in ansible_run_tags"
|
|
|
|
ansible.builtin.shell: pihole -up
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: Check if pi-hole db exists
|
|
|
|
stat:
|
|
|
|
path: /etc/pihole/gravity.db
|
|
|
|
register: pihole_db
|
|
|
|
|
|
|
|
- name: Install sqlite3 package
|
|
|
|
ansible.builtin.package:
|
|
|
|
name: sqlite3
|
|
|
|
|
|
|
|
- name: Install more lists than default
|
|
|
|
when: pihole_db.stat.exists
|
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: sqlite3 /etc/pihole/gravity.db "INSERT INTO adlist (address, enabled, comment) VALUES ('{{ item }}', 1, '');"
|
|
|
|
loop: "{{ pihole_custom_list }}"
|
|
|
|
when: "pihole_install_custom_list is true"
|
|
|
|
|
|
|
|
- name: Update Gravity
|
|
|
|
ansible.builtin.shell: pihole updateGravity
|
|
|
|
when: "
|
|
|
|
(pihole_install_custom_list is true) or
|
|
|
|
('pihole.update_gravity' in ansible_run_tags)
|
|
|
|
"
|