2024-03-23 20:22:58 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
meta,
|
|
|
|
name,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
let
|
|
|
|
inherit (config.networking) hostName domain;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
|
|
|
|
options.dgn-netbox-agent = {
|
|
|
|
enable = lib.mkEnableOption "DGNum netbox agent setup." // {
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
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 = meta.nodes.${name}.vm-cluster != null;
|
|
|
|
cluster_name = meta.nodes.${name}.vm-cluster;
|
|
|
|
};
|
|
|
|
purge_old_devices = true;
|
|
|
|
hostname_cmd = "echo ${hostName}.${domain}";
|
|
|
|
datacenter_location = {
|
|
|
|
driver = "cmd:echo ${meta.nodes.${name}.site}";
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
age-secrets.sources = [ ./. ];
|
|
|
|
};
|
|
|
|
}
|