nixos/consul: fix consul alerts enable
This commit is contained in:
parent
cc96e474d3
commit
c9da002a07
@ -106,6 +106,12 @@ in
|
||||
alerts = {
|
||||
enable = mkEnableOption "Whether to enable consul-alerts";
|
||||
|
||||
package = mkOption {
|
||||
description = "Package to use for consul-alerts.";
|
||||
default = pkgs.consul-alerts;
|
||||
type = types.package;
|
||||
};
|
||||
|
||||
listenAddr = mkOption {
|
||||
description = "Api listening address.";
|
||||
default = "localhost:9000";
|
||||
@ -135,7 +141,8 @@ in
|
||||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
config = mkIf cfg.enable (
|
||||
mkMerge [{
|
||||
|
||||
users.extraUsers."consul" = {
|
||||
description = "Consul agent daemon user";
|
||||
@ -207,8 +214,10 @@ in
|
||||
echo "}" >> /etc/consul-addrs.json
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
systemd.services.consul-alerts = mkIf (cfg.alerts.enable) {
|
||||
(mkIf (cfg.alerts.enable) {
|
||||
systemd.services.consul-alerts = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "consul.service" ];
|
||||
|
||||
@ -216,15 +225,17 @@ in
|
||||
|
||||
serviceConfig = {
|
||||
ExecStart = ''
|
||||
${pkgs.consul-alerts}/bin/consul-alerts start \
|
||||
${cfg.alerts.package}/bin/consul-alerts start \
|
||||
--alert-addr=${cfg.alerts.listenAddr} \
|
||||
--consul-addr=${cfg.alerts.consulAddr} \
|
||||
${optionalString cfg.alerts.watchChecks "--watch-checks"} \
|
||||
${optionalString cfg.alerts.watchEvents "--watch-events"}
|
||||
'';
|
||||
User = if cfg.dropPrivileges then "consul" else null;
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
};
|
||||
]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user