Skip to content

Commit 22595ce

Browse files
committed
Merge branch 'renovate/gitlab-runner-0.x' into 'master'
1 parent 07c9270 commit 22595ce

26 files changed

+4578
-547
lines changed

ansible/inventory/host_vars/pihole.yml

Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pihole:
2-
api_url: "https://pihole.local.ildoc.it/admin"
2+
api_url: "https://pihole.local.ildoc.it"
33
api_key: "{{ lookup('community.hashi_vault.hashi_vault', 'ansible/data/pihole:api_key') }}"
4+
validate_certs: false # Set to true if you have valid SSL certificates
45
check_updates: true
56
auto_update: false
67

@@ -10,53 +11,44 @@ pihole:
1011
- { ip: 192.168.0.11, domain: "pve02" }
1112
- { ip: 192.168.0.12, domain: "pve03" }
1213

13-
- { ip: 192.168.0.111, domain: "invidious" }
14-
- { ip: 192.168.0.123, domain: "truenas" }
1514
- { ip: 192.168.0.124, domain: "web" }
1615
- { ip: 192.168.0.133, domain: "homeassistant" }
17-
- { ip: 192.168.0.145, domain: "pihole" }
18-
- { ip: 192.168.0.167, domain: "pihole2" }
1916
- { ip: 192.168.0.183, domain: "ubuntu" }
2017

2118
- { ip: 192.168.0.30, domain: "db" }
2219
- { ip: 192.168.0.40, domain: "redis" }
2320
- { ip: 192.168.0.50, domain: "vault" }
2421

25-
- { ip: 192.168.0.80, domain: "argocd.local.ildoc.it" }
26-
- { ip: 192.168.0.80, domain: "longhorn.local.ildoc.it" }
27-
- { ip: 192.168.0.80, domain: "rancher.local.ildoc.it" }
28-
- { ip: 192.168.0.80, domain: "traefik.local.ildoc.it" }
29-
- { ip: 192.168.0.80, domain: "sonarr.local.ildoc.it" }
30-
- { ip: 192.168.0.80, domain: "radarr.local.ildoc.it" }
31-
- { ip: 192.168.0.80, domain: "bazarr.local.ildoc.it" }
32-
- { ip: 192.168.0.80, domain: "prowlarr.local.ildoc.it" }
33-
- { ip: 192.168.0.80, domain: "jackett.local.ildoc.it" }
34-
- { ip: 192.168.0.80, domain: "flaresolverr.local.ildoc.it" }
35-
- { ip: 192.168.0.80, domain: "pdf.local.ildoc.it" }
36-
- { ip: 192.168.0.80, domain: "tools.local.ildoc.it" }
37-
- { ip: 192.168.0.80, domain: "change.local.ildoc.it" }
38-
- { ip: 192.168.0.80, domain: "truenas.local.ildoc.it" }
39-
- { ip: 192.168.0.80, domain: "mealie.local.ildoc.it" }
40-
- { ip: 192.168.0.80, domain: "wg.local.ildoc.it" }
41-
- { ip: 192.168.0.80, domain: "uptime.local.ildoc.it" }
42-
- { ip: 192.168.0.80, domain: "homepage.local.ildoc.it" }
43-
- { ip: 192.168.0.80, domain: "speedtest.local.ildoc.it" }
44-
- { ip: 192.168.0.80, domain: "nut.local.ildoc.it" }
45-
- { ip: 192.168.0.80, domain: "romm.local.ildoc.it" }
46-
- { ip: 192.168.0.80, domain: "zipline.local.ildoc.it" }
47-
- { ip: 192.168.0.80, domain: "invidious.local.ildoc.it" }
48-
- { ip: 192.168.0.80, domain: "readarr.local.ildoc.it" }
49-
- { ip: 192.168.0.80, domain: "bookbounty.local.ildoc.it" }
50-
- { ip: 192.168.0.80, domain: "kestra.local.ildoc.it" }
51-
- { ip: 192.168.0.80, domain: "paperless.local.ildoc.it" }
52-
- { ip: 192.168.0.80, domain: "kitchenowl.local.ildoc.it" }
53-
- { ip: 192.168.0.80, domain: "audiobookshelf.local.ildoc.it" }
54-
- { ip: 192.168.0.25, domain: "gitlab.local.ildoc.it" }
55-
- { ip: 192.168.0.25, domain: "registry.gitlab.local.ildoc.it" }
56-
57-
- { ip: 192.168.0.100, domain: "argocd2.local.ildoc.it" }
58-
- { ip: 192.168.0.100, domain: "traefik2.local.ildoc.it" }
59-
- { ip: 192.168.0.100, domain: "rancher2.local.ildoc.it" }
22+
- { ip: 192.168.0.145, domain: "pihole.local.ildoc.it"}
23+
- { ip: 192.168.0.183, domain: "ubuntu.local.ildoc.it"}
24+
25+
- { ip: 192.168.0.25, domain: "gitlab.local.ildoc.it"}
26+
- { ip: 192.168.0.25, domain: "registry.gitlab.local.ildoc.it"}
27+
28+
- { ip: 192.168.0.81, domain: "alertmanager.local.ildoc.it"}
29+
- { ip: 192.168.0.81, domain: "argocd.local.ildoc.it"}
30+
- { ip: 192.168.0.81, domain: "audiobookshelf.local.ildoc.it"}
31+
- { ip: 192.168.0.81, domain: "auth.local.ildoc.it"}
32+
- { ip: 192.168.0.81, domain: "bazarr.local.ildoc.it"}
33+
- { ip: 192.168.0.81, domain: "flaresolverr.local.ildoc.it"}
34+
- { ip: 192.168.0.81, domain: "grafana.local.ildoc.it"}
35+
- { ip: 192.168.0.81, domain: "n8n.local.ildoc.it"}
36+
- { ip: 192.168.0.81, domain: "nut.local.ildoc.it"}
37+
- { ip: 192.168.0.81, domain: "prometheus.local.ildoc.it"}
38+
- { ip: 192.168.0.81, domain: "prowlarr.local.ildoc.it"}
39+
- { ip: 192.168.0.81, domain: "radarr.local.ildoc.it"}
40+
- { ip: 192.168.0.81, domain: "rancher.local.ildoc.it"}
41+
- { ip: 192.168.0.81, domain: "sonar.local.ildoc.it"}
42+
- { ip: 192.168.0.81, domain: "sonarr.local.ildoc.it"}
43+
- { ip: 192.168.0.81, domain: "speedtest.local.ildoc.it"}
44+
- { ip: 192.168.0.81, domain: "tools.local.ildoc.it"}
45+
- { ip: 192.168.0.81, domain: "traefik.local.ildoc.it"}
46+
47+
- { ip: 192.168.0.82, domain: "invidious.local.ildoc.it"}
48+
- { ip: 192.168.0.82, domain: "pbs.local.ildoc.it"}
49+
- { ip: 192.168.0.82, domain: "proxmox.local.ildoc.it"}
50+
- { ip: 192.168.0.82, domain: "truenas.local.ildoc.it"}
51+
- { ip: 192.168.0.82, domain: "vault.local.ildoc.it"}
6052

6153
dhcp_reservations:
6254
- { mac: 60:83:E7:AC:6C:68, ip: 192.168.0.175, hostname: archlinux }
@@ -83,59 +75,73 @@ pihole:
8375
- { mac: aa:bb:cc:22:11:77, ip: 192.168.0.42, hostname: mongodb-db }
8476

8577
adlists:
86-
- url: "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
78+
- address: "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts"
79+
type: "block"
8780
comment: "Steven Black's Unified Hosts List"
8881
enabled: true
8982

90-
- url: "https://raw.githubusercontent.com/PolishFiltersTeam/KADhosts/master/KADhosts.txt"
83+
- address: "https://raw.githubusercontent.com/PolishFiltersTeam/KADhosts/master/KADhosts.txt"
84+
type: "block"
9185
comment: "KAD hosts"
9286
enabled: true
9387

94-
- url: https://v.firebog.net/hosts/AdguardDNS.txt
88+
- address: https://v.firebog.net/hosts/AdguardDNS.txt
89+
type: "block"
9590
comment: "Adguard DNS"
9691
enabled: true
9792

98-
- url: "https://v.firebog.net/hosts/Easyprivacy.txt"
93+
- address: "https://v.firebog.net/hosts/Easyprivacy.txt"
94+
type: "block"
9995
comment: "EasyPrivacy"
10096
enabled: true
10197

102-
- url: "https://www.github.developerdan.com/hosts/lists/ads-and-tracking-extended.txt"
98+
- address: "https://www.github.developerdan.com/hosts/lists/ads-and-tracking-extended.txt"
99+
type: "block"
103100
comment: "Ads and tracking extended"
104101
enabled: true
105102

106-
- url: "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Spam/hosts"
103+
- address: "https://raw.githubusercontent.com/FadeMind/hosts.extras/master/add.Spam/hosts"
104+
type: "block"
107105
comment: "FadeMind List"
108106
enabled: true
109107

110-
- url: "https://v.firebog.net/hosts/static/w3kbl.txt"
108+
- address: "https://v.firebog.net/hosts/static/w3kbl.txt"
109+
type: "block"
111110
comment: "Firebog w3kbl list"
112111
enabled: true
113112

114-
- url: "https://v.firebog.net/hosts/Prigent-Ads.txt"
113+
- address: "https://v.firebog.net/hosts/Prigent-Ads.txt"
114+
type: "block"
115115
comment: "Firebog Prigent ads list"
116116
enabled: true
117117

118-
- url: "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/pro.txt"
118+
- address: "https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/pro.txt"
119+
type: "block"
119120
comment: "Hagezi Pro Blocklist"
120121
enabled: true
121122

122-
- url: "https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/SmartTV-AGH.txt"
123+
- address: "https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/SmartTV-AGH.txt"
124+
type: "block"
123125
comment: "Smart TV AGH Blocklist"
124126
enabled: true
125127

126-
- url: "https://raw.githubusercontent.com/AdAway/adaway.github.io/master/hosts.txt"
128+
- address: "https://raw.githubusercontent.com/AdAway/adaway.github.io/master/hosts.txt"
129+
type: "block"
127130
comment: "AdAway Hosts"
128131
enabled: true
129132

130-
- url: "https://mirror1.malwaredomains.com/files/justdomains"
133+
- address: "https://mirror1.malwaredomains.com/files/justdomains"
134+
type: "block"
131135
comment: "Malware Domains"
132136
enabled: true
133137

134-
- url: "https://big.oisd.nl"
138+
- address: "https://big.oisd.nl"
139+
type: "block"
135140
comment: "OISD Full"
136141
enabled: true
137142

138-
- url: "https://someonewhocares.org/hosts/zero/hosts"
143+
- address: "https://someonewhocares.org/hosts/zero/hosts"
144+
type: "block"
139145
comment: "Dan Pollock's List"
140146
enabled: false # Esempio di lista disabilitata
141147

ansible/pihole6.yml

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

ansible/roles/pihole/handlers/main.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
# ansible/roles/pihole6/tasks/authenticate.yml
3+
# Authenticate to Pi-hole API and obtain a session ID (SID)
4+
5+
- name: Authenticate to Pi-hole API
6+
ansible.builtin.uri:
7+
url: "{{ pihole.api_url }}/api/auth"
8+
method: POST
9+
body_format: json
10+
body:
11+
password: "{{ pihole.api_key }}"
12+
status_code: [200]
13+
validate_certs: "{{ pihole.validate_certs | default(false) }}"
14+
return_content: true
15+
register: pihole_auth_response
16+
no_log: true # Don't log the password
17+
18+
- name: Extract session ID from authentication response
19+
ansible.builtin.set_fact:
20+
pihole_session_id: "{{ pihole_auth_response.json.session.sid }}"
21+
pihole_session_validity: "{{ pihole_auth_response.json.session.validity }}"
22+
no_log: true # Don't log the session ID
23+
24+
- name: Display session validity
25+
ansible.builtin.debug:
26+
msg: "Authenticated successfully. Session valid for {{ pihole_session_validity }} seconds"
Lines changed: 104 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,105 @@
11
---
2-
- name: Create DNS records file from template
3-
ansible.builtin.template:
4-
src: custom.list.j2
5-
dest: /etc/pihole/custom.list
6-
owner: root
7-
group: root
8-
mode: '0644'
9-
register: dns_records_result
10-
11-
- name: Restart pihole dns
12-
ansible.builtin.shell: pihole restartdns
13-
when: dns_records_result.changed
14-
15-
- name: Create DHCP leases file from template
16-
ansible.builtin.template:
17-
src: 04-pihole-static-dhcp.conf.j2
18-
dest: /etc/dnsmasq.d/04-pihole-static-dhcp.conf
19-
owner: root
20-
group: root
21-
mode: '0644'
22-
register: dhcp_conf_result
23-
24-
- name: Update DHCP leases if necessary
25-
ansible.builtin.include_tasks: update_dhcp_leases.yml
26-
when: dhcp_conf_result.changed
2+
# ansible/roles/pihole6/tasks/main.yml
3+
4+
- name: Ensure required variables are defined
5+
ansible.builtin.assert:
6+
that:
7+
- pihole.api_key is defined
8+
- pihole.api_url is defined
9+
fail_msg: "pihole.api_key and pihole.api_url must be defined"
10+
11+
# Authenticate and get session ID
12+
- name: Authenticate to Pi-hole API
13+
ansible.builtin.include_tasks: authenticate.yml
14+
tags: ['always']
15+
16+
# DNS Records (managed via /api/config - dns.hosts)
17+
- name: Manage DNS records via API
18+
ansible.builtin.include_tasks: manage_dns_records.yml
19+
when: pihole.dns_records is defined
20+
tags: ['dns']
21+
22+
# # DHCP Reservations (managed via /api/config - dhcp.hosts)
23+
# - name: Manage DHCP reservations via API
24+
# ansible.builtin.include_tasks: manage_dhcp_reservations.yml
25+
# when: pihole.dhcp_reservations is defined
26+
# tags: ['dhcp']
27+
28+
# Adlists (managed via /api/lists)
29+
- name: Manage Adlists via API
30+
ansible.builtin.include_tasks: manage_pihole_resource.yml
31+
vars:
32+
resource_name: "adlists"
33+
api_endpoint: "lists"
34+
key_attribute: "address"
35+
desired_resources: "{{ pihole.adlists }}"
36+
is_list: true
37+
trigger_gravity: true
38+
when: pihole.adlists is defined
39+
tags: ['adlists', 'lists']
40+
41+
# Whitelist Domains (managed via /api/domains/allow/exact)
42+
- name: Manage Whitelist domains via API
43+
ansible.builtin.include_tasks: manage_pihole_resource.yml
44+
vars:
45+
resource_name: "whitelist domains"
46+
api_endpoint: "domains/allow/exact"
47+
key_attribute: "domain"
48+
desired_resources: "{{ pihole.whitelist.domains }}"
49+
is_list: false
50+
domain_type: "allow"
51+
domain_kind: "exact"
52+
when: pihole.whitelist.domains is defined
53+
tags: ['whitelist', 'domains']
54+
55+
# Whitelist Regex (managed via /api/domains/allow/regex)
56+
- name: Manage Whitelist regex via API
57+
ansible.builtin.include_tasks: manage_pihole_resource.yml
58+
vars:
59+
resource_name: "whitelist regex"
60+
api_endpoint: "domains/allow/regex"
61+
key_attribute: "domain"
62+
desired_resources: "{{ pihole.whitelist.regex }}"
63+
is_list: false
64+
domain_type: "allow"
65+
domain_kind: "regex"
66+
when: pihole.whitelist.regex is defined
67+
tags: ['whitelist', 'domains']
68+
69+
# Blacklist Domains (managed via /api/domains/deny/exact)
70+
- name: Manage Blacklist domains via API
71+
ansible.builtin.include_tasks: manage_pihole_resource.yml
72+
vars:
73+
resource_name: "blacklist domains"
74+
api_endpoint: "domains/deny/exact"
75+
key_attribute: "domain"
76+
desired_resources: "{{ pihole.blacklist.domains }}"
77+
is_list: false
78+
domain_type: "deny"
79+
domain_kind: "exact"
80+
when: pihole.blacklist.domains is defined
81+
tags: ['blacklist', 'domains']
82+
83+
# Blacklist Regex (managed via /api/domains/deny/regex)
84+
- name: Manage Blacklist regex via API
85+
ansible.builtin.include_tasks: manage_pihole_resource.yml
86+
vars:
87+
resource_name: "blacklist regex"
88+
api_endpoint: "domains/deny/regex"
89+
key_attribute: "domain"
90+
desired_resources: "{{ pihole.blacklist.regex }}"
91+
is_list: false
92+
domain_type: "deny"
93+
domain_kind: "regex"
94+
when: pihole.blacklist.regex is defined
95+
tags: ['blacklist', 'domains']
96+
97+
- name: Update gravity if lists changed
98+
ansible.builtin.include_tasks: update_gravity.yml
99+
when: adlists_changed is defined and adlists_changed
100+
tags: ['gravity', 'lists']
101+
102+
- name: Check and update Pi-hole
103+
ansible.builtin.include_tasks: update_pihole.yml
104+
when: pihole.check_updates | default(true)
105+
tags: ['updates']

0 commit comments

Comments
 (0)