nixos/tests/prometheus-exporters/kea: migrate to kea nixos module

This commit is contained in:
Martin Weinelt 2021-07-12 01:36:50 +02:00
parent 508408559a
commit cf139f7203
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759
2 changed files with 18 additions and 30 deletions

View File

@ -26,6 +26,7 @@ in {
};
serviceOpts = {
serviceConfig = {
User = "kea";
ExecStart = ''
${pkgs.prometheus-kea-exporter}/bin/kea-exporter \
--address ${cfg.listenAddress} \

View File

@ -326,49 +326,36 @@ let
'';
};
kea = {
kea = let
controlSocketPath = "/run/kea/dhcp6.sock";
in
{
exporterConfig = {
enable = true;
controlSocketPaths = [
"/run/kea/kea-dhcp6.sock"
controlSocketPath
];
};
metricProvider = {
users.users.kea = {
isSystemUser = true;
};
users.groups.kea = {};
systemd.services.prometheus-kea-exporter.after = [ "kea-dhcp6-server.service" ];
systemd.services.prometheus-kea-exporter.after = [ "kea-dhcp6.service" ];
systemd.services.kea-dhcp6 = let
configFile = pkgs.writeText "kea-dhcp6.conf" (builtins.toJSON {
Dhcp6 = {
"control-socket" = {
"socket-type" = "unix";
"socket-name" = "/run/kea/kea-dhcp6.sock";
services.kea = {
enable = true;
dhcp6 = {
enable = true;
settings = {
control-socket = {
socket-type = "unix";
socket-name = controlSocketPath;
};
};
});
in
{
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
DynamicUser = false;
User = "kea";
Group = "kea";
ExecStart = "${pkgs.kea}/bin/kea-dhcp6 -c ${configFile}";
StateDirectory = "kea";
RuntimeDirectory = "kea";
UMask = "0007";
};
};
};
exporterTest = ''
wait_for_unit("kea-dhcp6.service")
wait_for_file("/run/kea/kea-dhcp6.sock")
wait_for_unit("kea-dhcp6-server.service")
wait_for_file("${controlSocketPath}")
wait_for_unit("prometheus-kea-exporter.service")
wait_for_open_port(9547)
succeed(