diff options
| author | Ahmed Abdelhalim <[email protected]> | 2025-08-31 21:03:54 +0200 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2025-08-31 21:03:54 +0200 |
| commit | 7cf6ad35a270b884b6651f5950f17864be2ec963 (patch) | |
| tree | 9d0515983a6283af9f563dad588158ad511a24dd /roles/pihole | |
| parent | ebc491774ce2dcea46310cc8dd32504086fea8ee (diff) | |
Update pihole role to function as dhcp for the network
Diffstat (limited to 'roles/pihole')
| -rw-r--r-- | roles/pihole/README.md | 6 | ||||
| -rw-r--r-- | roles/pihole/defaults/main.yml | 5 | ||||
| -rw-r--r-- | roles/pihole/meta/argument_specs.yml | 20 | ||||
| -rw-r--r-- | roles/pihole/templates/pihole.toml.j2 | 7 |
4 files changed, 36 insertions, 2 deletions
diff --git a/roles/pihole/README.md b/roles/pihole/README.md index 714ffd40..da95c866 100644 --- a/roles/pihole/README.md +++ b/roles/pihole/README.md @@ -19,8 +19,10 @@ This role configure the [pihole](https://github.com/pi-hole/pi-hole) DNS Sinkhol Update the following - Home Network > Network > Network Settings > Change Advanced Network Settings > - - IPv6 > DNSv6 Server in the Home Network > Router advertisement enable in the LAN > Set ULA Prefix - - IPv4 > DHCP > Local DNS Server > {{ pihole_ipv4 }} + - IPv6 > DNSv6 Server in the Home Network > Router advertisement enable in the LAN > Disabled + - IPv6 > DNSv6 Server in the Home Network > Disable DHCPv6 server in the FRITZ!Box > + - There are no other DHCPv6 servers in the home network. + - IPv4 > DHCP > Enable DHCP server > Disabled - Internet > Account Information > DNS Server > DNSv4 Server > - Use Other DNSv4 Servers > {{ pihole_ipv4 }} - Use Other DNSv6 Servers > {{ pihole_ipv6 }} diff --git a/roles/pihole/defaults/main.yml b/roles/pihole/defaults/main.yml index e5edf117..44744d98 100644 --- a/roles/pihole/defaults/main.yml +++ b/roles/pihole/defaults/main.yml @@ -8,4 +8,9 @@ pihole_dns: pihole_interface: "{{ ansible_default_ipv4.interface }}" pihole_dns_blocking_enabled: true pihole_dhcp_enabled: false +pihole_dhcp_start: "{{ ansible_default_ipv4.network | regex_replace('\\.0$', '.100') }}" +pihole_dhcp_end: "{{ ansible_default_ipv4.network | regex_replace('\\.0$', '.199') }}" +pihole_dhcp_router: "{{ ansible_default_ipv4.address }}" +pihole_dhcp_lease_time: 24 +pihole_dhcp_domain: "local" pihole_domain: "" diff --git a/roles/pihole/meta/argument_specs.yml b/roles/pihole/meta/argument_specs.yml index b50fc5c5..e7cf04e7 100644 --- a/roles/pihole/meta/argument_specs.yml +++ b/roles/pihole/meta/argument_specs.yml @@ -30,6 +30,26 @@ argument_specs: type: "bool" description: "The boolean flag to toggle DHCP on the pi-hole" default: false + pihole_dhcp_start: + type: "str" + description: "The dhcp start address" + default: "{{ ansible_default_ipv4.network }}.100" + pihole_dhcp_end: + type: "str" + description: "The dhcp end address" + default: "{{ ansible_default_ipv4.network }}.199" + pihole_dhcp_address: + type: "str" + description: "The dhcp server address (local pihole address)" + default: "{{ ansible_default_ipv4.address }}" + pihole_dhcp_lease_time: + type: "int" + description: "The dhcp lease time in hours" + default: 24 + pihole_dhcp_domain: + type: "str" + description: "The dhcp local domain extension" + default: "local" pihole_domain: type: "str" description: "The domain name to be configured when the pi is exposed over the internet" diff --git a/roles/pihole/templates/pihole.toml.j2 b/roles/pihole/templates/pihole.toml.j2 index 78467364..67913821 100644 --- a/roles/pihole/templates/pihole.toml.j2 +++ b/roles/pihole/templates/pihole.toml.j2 @@ -47,6 +47,13 @@ active = {{ pihole_dns_blocking_enabled | lower }} [dhcp] active = {{ pihole_dhcp_enabled | lower }} +{% if pihole_dhcp_enabled %} +start = "{{ pihole_dhcp_start }}" +end = "{{ pihole_dhcp_end }}" +router = "{{ pihole_dhcp_router }}" +leaseTime = {{ pihole_dhcp_lease_time }} +domain = "{{ pihole_dhcp_domain }}" +{% endif %} [webserver] {% if (pihole_domain is defined) and (pihole_domain != '') %} |
