Skip to content

Commit ee81768

Browse files
committed
Update for pihole 6
Pihole 6 uses a different config file format and no longer supports the setupVars file. To change settings we need to use the pihole-FTL binary. Also it now uses an internal webserver instead of lighttp.
1 parent 877453d commit ee81768

File tree

5 files changed

+22
-58
lines changed

5 files changed

+22
-58
lines changed

inventory/host_vars/nas.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ container_proxy_routes:
131131
backend: http://192.168.1.10:9093
132132
icon: https://upload.wikimedia.org/wikipedia/commons/3/38/Prometheus_software_logo.svg
133133
- title: Pi-hole
134-
path: /pihole/
134+
path: /pihole/admin
135135
backend: http://192.168.1.5/admin/
136136
type: pihole
137137
icon: https://upload.wikimedia.org/wikipedia/en/1/15/Pi-hole_vector_logo.svg

roles/container-proxy/templates/container-proxy.j2

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,6 @@ map $http_upgrade $connection_upgrade {
66
}
77
{% endif %}
88

9-
{% for route in container_proxy_routes %}
10-
{% if route.type is defined and route.type == "pihole" %}
11-
map $upstream_http_location $replace_location_{{ route.path.replace('/', '') }} {
12-
"" "";
13-
"/admin/" "/pihole/";
14-
"~^/(.*)$" "/pihole/$1";
15-
"~^(.*)$" "/pihole/$1";
16-
}
17-
{% endif %}
18-
{% endfor %}
19-
209
server {
2110
listen 80 default_server;
2211
listen [::]:80 default_server;
@@ -46,14 +35,7 @@ server {
4635
{% elif _type == "pihole" %}
4736
location {{ route.path }} {
4837
proxy_pass {{ route.backend }};
49-
proxy_set_header Host $host;
50-
proxy_set_header X-Real-IP $remote_addr;
51-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
52-
proxy_hide_header X-Frame-Options;
53-
proxy_set_header X-Frame-Options "SAMEORIGIN";
54-
# we need to rewrite the location header pihole returns
55-
proxy_hide_header Location;
56-
add_header Location $replace_location_{{ route.path.replace('/', '') }};
38+
rewrite ^{{ route.path }}(.*) /$1 break;
5739
}
5840
{% elif _type == "grafana" %}
5941
location {{ route.path.rstrip("/") }}/ {

roles/pihole/defaults/main.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pihole_dns_2:
2+
pihole_dns_3:
3+
pihole_dns_4:

roles/pihole/tasks/main.yaml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,26 @@
1717
mode: "0775"
1818
state: directory
1919

20-
- name: Create pihole setupvars
21-
ansible.builtin.template:
22-
src: ./templates/setupVars.conf.j2
23-
dest: /etc/pihole/setupVars.conf
24-
register: pihole_setupvars
25-
2620
- name: Install pi-hole
2721
ansible.builtin.command: "'/etc/.pihole/automated install/basic-install.sh' --unattended"
2822
args:
2923
creates: /opt/pihole
3024
register: pihole_install
3125

32-
- name: Reconfigure pi-hole after setupvars change
33-
ansible.builtin.command: "'/etc/.pihole/automated install/basic-install.sh' --reconfigure --unattended"
34-
when:
35-
- not pihole_install.changed
36-
- pihole_setupvars.changed
26+
- name: Set Pi-hole configuration settings
27+
ansible.builtin.command:
28+
cmd: "pihole-FTL --config {{ item.key }} '{{ item.value }}'"
29+
with_items:
30+
- { key: "dns.upstreams", value: "{{ [pihole_dns_1, pihole_dns_2, pihole_dns_3, pihole_dns_4]
31+
| select('defined')
32+
| select('string')
33+
| to_json
34+
}}"
35+
}
36+
- { key: "webserver.paths.prefix", value: "/pihole" }
37+
register: pihole_config
38+
39+
- name: Set Pi-hole Web password
40+
ansible.builtin.command:
41+
cmd: "pihole-FTL --config webserver.api.password '{{ pihole_web_password }}'"
42+
no_log: true

roles/pihole/templates/setupVars.conf.j2

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)