2024-12-12 14:41:43 +01:00
|
|
|
# SPDX-FileCopyrightText: 2024 Maurice Debray <maurice.debray@dgnum.eu>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
2024-03-23 20:22:58 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
2024-04-18 15:53:20 +02:00
|
|
|
nodeMeta,
|
2024-03-23 20:22:58 +01:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
inherit (config.networking) hostName domain;
|
|
|
|
in
|
2024-10-21 10:40:33 +02:00
|
|
|
|
2024-03-23 20:22:58 +01:00
|
|
|
{
|
2024-10-21 10:40:33 +02:00
|
|
|
imports = [ ./module.nix ];
|
2024-03-23 20:22:58 +01:00
|
|
|
|
|
|
|
options.dgn-netbox-agent = {
|
|
|
|
enable = lib.mkEnableOption "DGNum netbox agent setup." // {
|
2024-11-19 12:02:28 +01:00
|
|
|
default = false;
|
2024-03-23 20:22:58 +01:00
|
|
|
};
|
|
|
|
};
|
2024-05-07 13:29:43 +02:00
|
|
|
|
2024-03-23 20:22:58 +01:00
|
|
|
config = lib.mkIf config.dgn-netbox-agent.enable {
|
|
|
|
services.netbox-agent = {
|
|
|
|
enable = true;
|
2024-05-07 13:29:43 +02:00
|
|
|
|
2024-03-23 20:22:58 +01:00
|
|
|
settings = {
|
|
|
|
netbox.url = "https://netbox.dgnum.eu/";
|
|
|
|
network.ignore_interfaces = "(lo|dummy.*|docker.*|podman.*)";
|
|
|
|
register = true;
|
|
|
|
update_all = true;
|
|
|
|
virtual = {
|
2024-04-18 15:53:20 +02:00
|
|
|
enabled = nodeMeta.vm-cluster != null;
|
|
|
|
cluster_name = nodeMeta.vm-cluster;
|
2024-03-23 20:22:58 +01:00
|
|
|
};
|
|
|
|
purge_old_devices = true;
|
|
|
|
hostname_cmd = "echo ${hostName}.${domain}";
|
|
|
|
datacenter_location = {
|
2024-04-18 15:53:20 +02:00
|
|
|
driver = "cmd:echo ${nodeMeta.site}";
|
2024-03-23 20:22:58 +01:00
|
|
|
regex = "(.*)";
|
|
|
|
};
|
|
|
|
device = {
|
|
|
|
tags = "netbox-agent";
|
|
|
|
# Default role
|
|
|
|
server_role = "Staging infra";
|
|
|
|
};
|
|
|
|
};
|
2024-04-13 15:11:27 +02:00
|
|
|
randomizedDelaySec = "3h";
|
2024-03-23 20:22:58 +01:00
|
|
|
environmentFile = config.age.secrets."netbox-agent".path;
|
|
|
|
};
|
2024-10-21 10:40:33 +02:00
|
|
|
|
|
|
|
age-secrets.sources = [ ./secrets ];
|
2024-03-23 20:22:58 +01:00
|
|
|
};
|
|
|
|
}
|