1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-11 07:10:39 +02:00

feat: automatically provision tokens for telegraf

This commit is contained in:
oddlama 2023-08-16 00:17:47 +02:00
parent 6a14451033
commit 377da23c0d
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
10 changed files with 288 additions and 285 deletions

View file

@ -3,6 +3,7 @@
lib,
nodes,
utils,
pkgs,
...
}: let
sentinelCfg = nodes.sentinel.config;
@ -51,14 +52,54 @@ in {
};
};
age.secrets.influxdb-admin-password = {
generator.script = "alnum";
mode = "440";
group = "influxdb2";
};
age.secrets.influxdb-admin-token = {
generator.script = "alnum";
mode = "440";
group = "influxdb2";
};
age.secrets.influxdb-user-telegraf-token = {
generator.script = "alnum";
mode = "440";
group = "influxdb2";
};
services.influxdb2 = {
enable = true;
settings = {
reporting-disabled = true;
http-bind-address = "${config.meta.wireguard.proxy-sentinel.ipv4}:${toString influxdbPort}";
};
provision = {
enable = true;
initialSetup = {
organization = "default";
bucket = "default";
passwordFile = config.age.secrets.influxdb-admin-password.path;
tokenFile = config.age.secrets.influxdb-admin-token.path;
};
ensureOrganizations = [
{
name = "servers";
}
];
ensureBuckets = [
{
name = "telegraf";
org = "servers";
}
];
};
};
environment.systemPackages = [pkgs.influxdb2-cli];
systemd.services.influxdb2 = {
after = ["sys-subsystem-net-devices-${utils.escapeSystemdPath "proxy-sentinel"}.device"];
serviceConfig.RestartSec = "600"; # Retry every 10 minutes