infrastructure/modules/dgn-netbox-agent/default.nix

57 lines
1.3 KiB
Nix
Raw Normal View History

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
{
options.dgn-netbox-agent = {
enable = lib.mkEnableOption "DGNum netbox agent setup." // {
default = true;
};
};
2024-03-23 20:22:58 +01:00
config = lib.mkIf config.dgn-netbox-agent.enable {
nixpkgs.overlays = [
(_: super: {
netbox-agent = super.netbox-agent.overrideAttrs (old: {
patches = (old.patches or [ ]) ++ [ ./01-batch-filter.patch ];
});
})
];
2024-03-23 20:22:58 +01:00
services.netbox-agent = {
enable = true;
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";
};
};
randomizedDelaySec = "3h";
2024-03-23 20:22:58 +01:00
environmentFile = config.age.secrets."netbox-agent".path;
};
age-secrets.sources = [ ./. ];
};
}