2023-11-13 08:30:11 +01:00
|
|
|
# Class to install and configure ISC Kea DHCP service.
|
|
|
|
# Check https://kb.isc.org/docs/kea-configuration-sections-explained for details
|
|
|
|
# for each parameter.
|
2023-11-12 15:49:08 +01:00
|
|
|
#
|
|
|
|
# [*ensure*]
|
|
|
|
# present or absent. Default: present
|
|
|
|
#
|
2023-11-13 08:30:11 +01:00
|
|
|
# [*dhcp4_conf*]
|
|
|
|
# Hash with the DHCP 4 service configuration.
|
|
|
|
#
|
|
|
|
# [*dhcp6_conf*]
|
|
|
|
# Hash with the DHCP 4 service configuration.
|
|
|
|
#
|
|
|
|
# [*ddns_conf*]
|
|
|
|
# Hash with the Dynamic DNS configuration.
|
|
|
|
#
|
|
|
|
# [*ctrl_agent_conf*]
|
|
|
|
# Hash with the Control Agent configuration.
|
|
|
|
#
|
2023-11-12 15:49:08 +01:00
|
|
|
# [*api_password*]
|
|
|
|
# (Sensitive) String API password.
|
|
|
|
#
|
|
|
|
class kea (
|
|
|
|
String $ensure = 'present',
|
2023-11-13 08:30:11 +01:00
|
|
|
Hash $dhcp4_conf = {},
|
|
|
|
Hash $dhcp6_conf = {},
|
|
|
|
Hash $ddns_conf = {},
|
|
|
|
Hash $ctrl_agent_conf = {},
|
|
|
|
Sensitive[String[1]] $api_password = '',
|
2023-11-12 15:49:08 +01:00
|
|
|
) {
|
|
|
|
case $ensure {
|
|
|
|
default: {
|
|
|
|
$package_ensure = 'latest'
|
|
|
|
$directory_ensure = 'directory'
|
|
|
|
$link_ensure = 'link'
|
|
|
|
$service_ensure = 'running'
|
|
|
|
}
|
|
|
|
/^(absent|delete|uninstall|remove|unregister)$/: {
|
|
|
|
$package_ensure = 'absent'
|
|
|
|
$directory_ensure = 'absent'
|
|
|
|
$link_ensure = 'absent'
|
|
|
|
$service_ensure = 'stopped'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
package { 'kea':
|
|
|
|
ensure => $package_ensure,
|
|
|
|
}
|
2023-11-13 08:30:11 +01:00
|
|
|
file { '/etc/kea/kea-api-password':
|
|
|
|
ensure => $ensure,
|
|
|
|
content => $api_password,
|
|
|
|
mode => '0640',
|
|
|
|
require => Package['kea'],
|
|
|
|
notify => Service['kea'],
|
|
|
|
}
|
|
|
|
file { '/etc/kea/kea-dhcp4.conf':
|
|
|
|
ensure => $ensure,
|
|
|
|
content => to_json($dhcp4_conf),
|
|
|
|
mode => '0644',
|
|
|
|
require => Package['kea'],
|
|
|
|
notify => Service['kea'],
|
|
|
|
}
|
|
|
|
file { '/etc/kea/kea-dhcp6.conf':
|
2023-11-12 15:49:08 +01:00
|
|
|
ensure => $ensure,
|
2023-11-13 08:30:11 +01:00
|
|
|
content => to_json($dhcp6_conf),
|
|
|
|
mode => '0644',
|
|
|
|
require => Package['kea'],
|
|
|
|
notify => Service['kea'],
|
|
|
|
}
|
|
|
|
file { '/etc/kea/kea-dhcp-ddns.conf':
|
|
|
|
ensure => $ensure,
|
|
|
|
content => to_json($ddns_conf),
|
|
|
|
mode => '0644',
|
|
|
|
require => Package['kea'],
|
|
|
|
notify => Service['kea'],
|
|
|
|
}
|
|
|
|
file { '/etc/kea/kea-ctrl-agent.conf':
|
|
|
|
ensure => $ensure,
|
|
|
|
content => to_json($ctrl_agent_conf),
|
|
|
|
mode => '0644',
|
|
|
|
require => Package['kea'],
|
|
|
|
notify => Service['kea'],
|
|
|
|
}
|
|
|
|
service { 'kea':
|
|
|
|
ensure => $service_ensure,
|
2023-11-12 15:49:08 +01:00
|
|
|
require => Package['kea'],
|
|
|
|
}
|
|
|
|
}
|