forked from DGNum/infrastructure
Tom Hubrecht
88d9b8c3e3
Signed-off-by: Tom Hubrecht <tom.hubrecht@dgnum.eu> Acked-by: Ryan Lahfa <ryan.lahfa@dgnum.eu> Acked-by: Maurice Debray <maurice.debray@dgnum.eu> Acked-by: Lubin Bailly <lubin.bailly@dgnum.eu> Acked-by: Jean-Marc Gailis <jean-marc.gailis@dgnum.eu> as the legal authority, at the time of writing, in DGNum. Acked-by: Elias Coppens <elias.coppens@dgnum.eu> as a member, at the time of writing, of the DGNum executive counsel.
55 lines
1.3 KiB
Nix
55 lines
1.3 KiB
Nix
# SPDX-FileCopyrightText: 2024 Maurice Debray <maurice.debray@dgnum.eu>
|
|
#
|
|
# SPDX-License-Identifier: EUPL-1.2
|
|
|
|
{
|
|
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 ];
|
|
};
|
|
}
|