Ansible role for installing and configuring a KEA DHCP server
- Jinja 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
ci/woodpecker/push/linting Pipeline was successful
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
| .woodpecker | ||
| defaults | ||
| handlers | ||
| meta | ||
| roles | ||
| tasks | ||
| templates | ||
| .ansible-lint | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| .markdownlint-cli2.jsonc | ||
| .sops.yaml | ||
| .yamllint | ||
| AGENTS.md | ||
| ansible.cfg | ||
| playbook.yaml | ||
| readme.md | ||
| renovate.json | ||
Ansible Role: KEA DHCP
Install and configure the KEA DHCP IPv4 server (kea-dhcp4) with a memfile lease
database, subnets, pools and host reservations.
Requirements
| Operating System | Package | Service |
|---|---|---|
| Debian | kea-dhcp4-server |
kea-dhcp4-server |
| Alpine | kea-dhcp4 |
kea-dhcp4 |
Dependencies
None (dependencies: []). The playbook only runs the dhcp role.
Variables
| Variable | Required | Default | Description |
|---|---|---|---|
kea_dhcp_interface |
No | eth0 |
Network interface to listen on |
kea_dhcp_lease_rebind |
No | 750 |
Rebind timer in seconds |
kea_dhcp_lease_renew |
No | 600 |
Renew timer in seconds |
kea_dhcp_lease_lifetime |
No | 900 |
Lease lifetime in seconds |
kea_dhcp_subnets |
Yes | one example subnet | List of DHCP subnets to configure |
The default of kea_dhcp_subnets is only an example (example-lan, 192.168.1.0/24). Always override it.
Subnets
| Key | Required | Description |
|---|---|---|
name |
Yes | Name of the subnet (informational, not rendered) |
subnet |
Yes | Subnet in CIDR notation |
pool |
Yes | Address pool, for example 192.168.1.100 - 192.168.1.200 |
gateway |
Yes | Router handed out as the routers option |
dns |
Yes | DNS server handed out as domain-name-servers |
reservations |
No | List of reservations |
Reservations
| Key | Required | Description |
|---|---|---|
hostname |
Yes | Hostname of the client |
ip |
Yes | Reserved IP address |
mac |
Yes | Hardware address of the client |
Example
kea_dhcp_interface: "eth0"
kea_dhcp_lease_lifetime: "3600"
kea_dhcp_subnets:
- name: "production-lan"
subnet: "192.168.1.0/24"
pool: "192.168.1.100 - 192.168.1.200"
gateway: "192.168.1.1"
dns: "192.168.1.10"
reservations:
- hostname: "server.example.com"
ip: "192.168.1.50"
mac: "AA:BB:CC:DD:EE:FF"
Usage
Run the role through Semaphore using playbook.yaml. The playbook first runs
ansible-galaxy install -f -r roles/requirements.yml to refresh the role, then runs the dhcp role.
Notes
| Item | Value |
|---|---|
| Configuration | /etc/kea/kea-dhcp4.conf |
| Leases | /var/lib/kea/dhcp4.leases (memfile, persisted) |
| Subnet IDs | Assigned by list position (first subnet is 1) |
A change to the configuration restarts the KEA service. Reordering subnets changes their IDs.