mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 12:29:02 +02:00
nixos/alertmanager: add environmentFile, envsubst for secrets
This commit is contained in:
parent
a605fcabae
commit
23d5d9bbe9
|
@ -18,7 +18,7 @@ let
|
||||||
in checkedConfig yml;
|
in checkedConfig yml;
|
||||||
|
|
||||||
cmdlineArgs = cfg.extraFlags ++ [
|
cmdlineArgs = cfg.extraFlags ++ [
|
||||||
"--config.file ${alertmanagerYml}"
|
"--config.file /tmp/alert-manager-substituted.yaml"
|
||||||
"--web.listen-address ${cfg.listenAddress}:${toString cfg.port}"
|
"--web.listen-address ${cfg.listenAddress}:${toString cfg.port}"
|
||||||
"--log.level ${cfg.logLevel}"
|
"--log.level ${cfg.logLevel}"
|
||||||
] ++ (optional (cfg.webExternalUrl != null)
|
] ++ (optional (cfg.webExternalUrl != null)
|
||||||
|
@ -127,6 +127,16 @@ in {
|
||||||
Extra commandline options when launching the Alertmanager.
|
Extra commandline options when launching the Alertmanager.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environmentFile = mkOption {
|
||||||
|
type = types.nullOr types.path;
|
||||||
|
default = null;
|
||||||
|
example = "/root/alertmanager.env";
|
||||||
|
description = ''
|
||||||
|
File to load as environment file. Useful to insert secrets
|
||||||
|
into the configuration (via envsubst).
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -144,9 +154,14 @@ in {
|
||||||
systemd.services.alertmanager = {
|
systemd.services.alertmanager = {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
|
preStart = ''
|
||||||
|
${lib.getBin pkgs.envsubst}/bin/envsubst -o /tmp/alert-manager-substituted.yaml" \
|
||||||
|
-i ${alertmanagerYml}"
|
||||||
|
'';
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
DynamicUser = true;
|
DynamicUser = true; # implies PrivateTmp
|
||||||
|
EnvironmentFile = lib.mkIf (cfg.environmentFile != null) cfg.environmentFile;
|
||||||
WorkingDirectory = "/tmp";
|
WorkingDirectory = "/tmp";
|
||||||
ExecStart = "${cfg.package}/bin/alertmanager" +
|
ExecStart = "${cfg.package}/bin/alertmanager" +
|
||||||
optionalString (length cmdlineArgs != 0) (" \\\n " +
|
optionalString (length cmdlineArgs != 0) (" \\\n " +
|
||||||
|
|
Loading…
Reference in a new issue