diff options
| author | Ahmed Abdelhalim <[email protected]> | 2025-09-02 04:38:23 +0200 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2025-09-02 04:51:13 +0200 |
| commit | a61e33c2ce6f138536492e006de7faf76662916a (patch) | |
| tree | 99ee4b5f7f962e4fa16ed19556cd0d83b31a8ca8 | |
| parent | ac410cee8f7ca8d199f61f92788e99867865b36e (diff) | |
Configure dhcp hosts in pihole role
| -rw-r--r-- | host_vars/rpi5.local.yml | bin | 547 -> 716 bytes | |||
| -rw-r--r-- | host_vars/rpi5.local.yml.example | 7 | ||||
| -rw-r--r-- | roles/pihole/defaults/main.yml | 1 | ||||
| -rw-r--r-- | roles/pihole/meta/argument_specs.yml | 5 | ||||
| -rw-r--r-- | roles/pihole/templates/pihole.toml.j2 | 1 |
5 files changed, 14 insertions, 0 deletions
diff --git a/host_vars/rpi5.local.yml b/host_vars/rpi5.local.yml Binary files differindex 9793f631..e571289d 100644 --- a/host_vars/rpi5.local.yml +++ b/host_vars/rpi5.local.yml diff --git a/host_vars/rpi5.local.yml.example b/host_vars/rpi5.local.yml.example index e195ccfc..1fc19dd1 100644 --- a/host_vars/rpi5.local.yml.example +++ b/host_vars/rpi5.local.yml.example @@ -8,6 +8,13 @@ network_ipv6_gateway: "fd5c:fd8b:2b8c::1" # TOTP generator: `openssl rand -base64 32 | head -c "20" | base32` pihole_totp_secret: "CHANGEME" pihole_password: "{{ ('changeme' | hash('sha256') | hash('sha256'))[:64] }}" +pihole_dhcp_enabled: true +pihole_dhcp_start: "10.0.0.100" +pihole_dhcp_end: "10.0.0.199" +pihole_dhcp_router: "10.0.0.200" +pihole_dhcp_hosts: + - "ff:ff:ff:ff:ff:fe, 10.0.0.252,TV" + - "ff:ff:ff:ff:ff:ff, 10.0.0.253,Printer" wireguard_gateway_enabled: true wireguard_autostart_connection: "protonvpn-us-1" diff --git a/roles/pihole/defaults/main.yml b/roles/pihole/defaults/main.yml index 7be113a4..1abac8e9 100644 --- a/roles/pihole/defaults/main.yml +++ b/roles/pihole/defaults/main.yml @@ -16,4 +16,5 @@ 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_dhcp_hosts: [] pihole_domain: "" diff --git a/roles/pihole/meta/argument_specs.yml b/roles/pihole/meta/argument_specs.yml index 9af61251..825d82d7 100644 --- a/roles/pihole/meta/argument_specs.yml +++ b/roles/pihole/meta/argument_specs.yml @@ -53,6 +53,11 @@ argument_specs: type: "str" description: "The dhcp local domain extension" default: "local" + pihole_dhcp_hosts: + type: "list" + description: "The list of static DHCP host reservations (format: MAC,IP,hostname)" + elements: "str" + default: [] 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 67913821..8fc5571d 100644 --- a/roles/pihole/templates/pihole.toml.j2 +++ b/roles/pihole/templates/pihole.toml.j2 @@ -53,6 +53,7 @@ end = "{{ pihole_dhcp_end }}" router = "{{ pihole_dhcp_router }}" leaseTime = {{ pihole_dhcp_lease_time }} domain = "{{ pihole_dhcp_domain }}" +hosts = {{ pihole_dhcp_hosts | to_nice_json }} {% endif %} [webserver] |
