Ansible role for installing and configuring a KEA DHCP server
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Simon Cornet e82abf57a6
All checks were successful
ci/woodpecker/push/linting Pipeline was successful
docs: improve readme
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-05 17:28:45 +02:00
.woodpecker chore(package): update cr.simoncor.net/dockerhub/davidanson/markdownlint-cli2 docker tag to v0.23.3 2026-09-20 05:47:09 +00:00
defaults style: remove trailing spaces 2025-07-15 15:15:49 +02:00
handlers chore: migrate bare ansible_* facts to ansible_facts[] syntax 2026-05-19 09:19:03 +02:00
meta feat: initial commit 2025-07-15 15:14:25 +02:00
roles ci: migrate from gitlab ci to woodpecker 2026-05-15 14:31:04 +02:00
tasks chore: migrate bare ansible_* facts to ansible_facts[] syntax 2026-05-19 09:19:03 +02:00
templates fix: add id with a loop index 2025-08-18 10:29:55 +02:00
.ansible-lint fix: exclude only sops yml files from lint 2026-07-14 16:23:38 +02:00
.editorconfig chore: add .editorconfig and .gitattributes 2026-05-27 14:23:42 +02:00
.gitattributes chore: add .editorconfig and .gitattributes 2026-05-27 14:23:42 +02:00
.gitignore feat: initial commit 2025-07-15 15:14:25 +02:00
.markdownlint-cli2.jsonc ci: migrate from gitlab ci to woodpecker 2026-05-15 14:31:04 +02:00
.sops.yaml fix: correct sops regex to ya?ml 2026-07-14 16:01:45 +02:00
.yamllint chore: exclude .yml files from lint configs 2026-07-14 16:17:21 +02:00
AGENTS.md chore: add AGENTS.md for opencode agents 2026-02-16 10:06:22 +01:00
ansible.cfg chore: sync linting and config files from common 2026-07-14 11:33:15 +02:00
playbook.yaml chore(playbook): run galaxy install only on first host 2026-08-13 08:49:03 +02:00
readme.md docs: improve readme 2026-10-05 17:28:45 +02:00
renovate.json feat: initial commit 2025-07-15 15:14:25 +02:00

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.