infrastructure/modules/dgn-netbox-agent/default.nix
2024-11-25 15:18:28 +01:00

51 lines
1.1 KiB
Nix

{
config,
lib,
nodeMeta,
...
}:
let
inherit (config.networking) hostName domain;
in
{
imports = [ ./module.nix ];
options.dgn-netbox-agent = {
enable = lib.mkEnableOption "DGNum netbox agent setup." // {
default = false;
};
};
config = lib.mkIf config.dgn-netbox-agent.enable {
services.netbox-agent = {
enable = true;
settings = {
netbox.url = "https://netbox.dgnum.eu/";
network.ignore_interfaces = "(lo|dummy.*|docker.*|podman.*)";
register = true;
update_all = true;
virtual = {
enabled = nodeMeta.vm-cluster != null;
cluster_name = nodeMeta.vm-cluster;
};
purge_old_devices = true;
hostname_cmd = "echo ${hostName}.${domain}";
datacenter_location = {
driver = "cmd:echo ${nodeMeta.site}";
regex = "(.*)";
};
device = {
tags = "netbox-agent";
# Default role
server_role = "Staging infra";
};
};
randomizedDelaySec = "3h";
environmentFile = config.age.secrets."netbox-agent".path;
};
age-secrets.sources = [ ./secrets ];
};
}