mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 06:00:33 +03:00
netdata module: add automatic claim
Allow machines to auto-register themselves by passing the claim token.
This commit is contained in:
parent
f2c3d5f5cf
commit
f4d5a76a81
1 changed files with 28 additions and 1 deletions
|
@ -159,6 +159,15 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
claim_token_file = mkOption {
|
||||||
|
type = types.nullOr types.path;
|
||||||
|
default = null;
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
If set, automatically registers the agent using the given claim token
|
||||||
|
file.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
enableAnalyticsReporting = mkOption {
|
enableAnalyticsReporting = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
@ -246,7 +255,25 @@ in {
|
||||||
PrivateTmp = true;
|
PrivateTmp = true;
|
||||||
ProtectControlGroups = true;
|
ProtectControlGroups = true;
|
||||||
PrivateMounts = true;
|
PrivateMounts = true;
|
||||||
};
|
} // (lib.optionalAttrs (cfg.claim_token_file != null) {
|
||||||
|
LoadCredential = [
|
||||||
|
"netdata_claim_token:${cfg.claim_token_file}"
|
||||||
|
];
|
||||||
|
|
||||||
|
ExecStartPre = pkgs.writeShellScript "netdata-claim" ''
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if [[ -f /var/lib/netdata/cloud.d/claimed_id ]]; then
|
||||||
|
# Already registered
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec ${cfg.package}/bin/netdata-claim.sh \
|
||||||
|
-token="$(< "$CREDENTIALS_DIRECTORY/netdata_claim_token")" \
|
||||||
|
-url=https://app.netdata.cloud \
|
||||||
|
-daemon-not-running
|
||||||
|
'';
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.enableCgroupAccounting = true;
|
systemd.enableCgroupAccounting = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue