nixos/promtail: configFile for passing path as config (#322426)
This commit is contained in:
@@ -10,15 +10,29 @@ let
|
|||||||
|
|
||||||
allowPositionsFile = !lib.hasPrefix "/var/cache/promtail" positionsFile;
|
allowPositionsFile = !lib.hasPrefix "/var/cache/promtail" positionsFile;
|
||||||
positionsFile = cfg.configuration.positions.filename;
|
positionsFile = cfg.configuration.positions.filename;
|
||||||
|
|
||||||
|
configFile = if cfg.configFile != null
|
||||||
|
then cfg.configFile
|
||||||
|
else prettyJSON cfg.configuration;
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options.services.promtail = with types; {
|
options.services.promtail = with types; {
|
||||||
enable = mkEnableOption "the Promtail ingresser";
|
enable = mkEnableOption "the Promtail ingresser";
|
||||||
|
|
||||||
|
|
||||||
configuration = mkOption {
|
configuration = mkOption {
|
||||||
type = (pkgs.formats.json {}).type;
|
type = (pkgs.formats.json {}).type;
|
||||||
description = ''
|
description = ''
|
||||||
Specify the configuration for Promtail in Nix.
|
Specify the configuration for Promtail in Nix.
|
||||||
|
This option will be ignored if `services.promtail.configFile` is defined.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
configFile = mkOption {
|
||||||
|
type = nullOr path;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
Config file path for Promtail.
|
||||||
|
If this option is defined, the value of `services.promtail.configuration` will be ignored.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,14 +56,14 @@ in {
|
|||||||
stopIfChanged = false;
|
stopIfChanged = false;
|
||||||
|
|
||||||
preStart = ''
|
preStart = ''
|
||||||
${lib.getExe pkgs.promtail} -config.file=${prettyJSON cfg.configuration} -check-syntax
|
${lib.getExe pkgs.promtail} -config.file=${configFile} -check-syntax
|
||||||
'';
|
'';
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
TimeoutStopSec = 10;
|
TimeoutStopSec = 10;
|
||||||
|
|
||||||
ExecStart = "${pkgs.promtail}/bin/promtail -config.file=${prettyJSON cfg.configuration} ${escapeShellArgs cfg.extraFlags}";
|
ExecStart = "${pkgs.promtail}/bin/promtail -config.file=${configFile} ${escapeShellArgs cfg.extraFlags}";
|
||||||
|
|
||||||
ProtectSystem = "strict";
|
ProtectSystem = "strict";
|
||||||
ProtectHome = true;
|
ProtectHome = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user