2023-09-09 16:40:10 +00:00
|
|
|
kea_config = {
|
|
|
|
'Dhcp4': {
|
|
|
|
**node.metadata.get('kea-dhcp-server/config'),
|
|
|
|
'interfaces-config': {
|
|
|
|
'interfaces': sorted(node.metadata.get('kea-dhcp-server/subnets', {}).keys()),
|
|
|
|
},
|
|
|
|
'subnet4': [],
|
|
|
|
'loggers': [{
|
|
|
|
'name': 'kea-dhcp4',
|
|
|
|
'output_options': [{
|
|
|
|
# -> journal
|
|
|
|
'output': 'stdout',
|
|
|
|
}],
|
|
|
|
'severity': 'WARN',
|
|
|
|
}],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for iface, config in sorted(node.metadata.get('kea-dhcp-server/subnets', {}).items()):
|
|
|
|
kea_config['Dhcp4']['subnet4'].append({
|
|
|
|
'subnet': config['subnet'],
|
|
|
|
'pools': [{
|
|
|
|
'pool': f'{config["lower"]} - {config["higher"]}',
|
|
|
|
}],
|
|
|
|
'option-data': [
|
|
|
|
{
|
|
|
|
'name': k,
|
|
|
|
'data': v,
|
|
|
|
} for k, v in sorted(config.get('options', {}).items())
|
|
|
|
],
|
|
|
|
'reservations': [
|
|
|
|
{
|
|
|
|
'ip-address': v['ip'],
|
|
|
|
'hw-address': v['mac'],
|
|
|
|
'hostname': k,
|
|
|
|
} for k, v in sorted(node.metadata.get(f'kea-dhcp-server/fixed_allocations/{iface}', {}).items())
|
|
|
|
]
|
|
|
|
})
|
|
|
|
|
2023-09-10 20:02:14 +00:00
|
|
|
files['/etc/kea/kea-dhcp4.conf'] = {
|
|
|
|
'content': repo.libs.faults.dict_as_json(kea_config),
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:kea-dhcp4-server:restart',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2024-01-30 20:01:20 +00:00
|
|
|
files['/usr/local/bin/kea-lease-list'] = {
|
|
|
|
'mode': '0500',
|
|
|
|
}
|
|
|
|
|
2023-09-10 20:02:14 +00:00
|
|
|
svc_systemd['kea-dhcp4-server'] = {
|
|
|
|
'needs': {
|
|
|
|
'file:/etc/kea/kea-dhcp4.conf',
|
|
|
|
'pkg_apt:kea-dhcp4-server',
|
|
|
|
},
|
|
|
|
}
|