Merge pull request #65810 from WilliButz/prometheus-exporters-replace-nobody
nixos/prometheus-exporters: replace nobody/nogroup
This commit is contained in:
commit
2eda061bb2
@ -219,6 +219,13 @@
|
|||||||
Nodejs 8 is scheduled EOL under the lifetime of 19.09 and has been dropped.
|
Nodejs 8 is scheduled EOL under the lifetime of 19.09 and has been dropped.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
By default, prometheus exporters are now run with <literal>DynamicUser</literal> enabled.
|
||||||
|
Exporters that need a real user, now run under a seperate user and group which follow the pattern <literal><exporter-name>-exporter</literal>, instead of the previous default <literal>nobody</literal> and <literal>nogroup</literal>.
|
||||||
|
Only some exporters are affected by the latter, namely the exporters <literal>dovecot</literal>, <literal>node</literal>, <literal>postfix</literal> and <literal>varnish</literal>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ let
|
|||||||
};
|
};
|
||||||
user = mkOption {
|
user = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "nobody";
|
default = "${name}-exporter";
|
||||||
description = ''
|
description = ''
|
||||||
User name under which the ${name} exporter shall be run.
|
User name under which the ${name} exporter shall be run.
|
||||||
Has no effect when <option>systemd.services.prometheus-${name}-exporter.serviceConfig.DynamicUser</option> is true.
|
Has no effect when <option>systemd.services.prometheus-${name}-exporter.serviceConfig.DynamicUser</option> is true.
|
||||||
@ -96,7 +96,7 @@ let
|
|||||||
};
|
};
|
||||||
group = mkOption {
|
group = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "nobody";
|
default = "${name}-exporter";
|
||||||
description = ''
|
description = ''
|
||||||
Group under which the ${name} exporter shall be run.
|
Group under which the ${name} exporter shall be run.
|
||||||
Has no effect when <option>systemd.services.prometheus-${name}-exporter.serviceConfig.DynamicUser</option> is true.
|
Has no effect when <option>systemd.services.prometheus-${name}-exporter.serviceConfig.DynamicUser</option> is true.
|
||||||
@ -127,8 +127,23 @@ let
|
|||||||
);
|
);
|
||||||
|
|
||||||
mkExporterConf = { name, conf, serviceOpts }:
|
mkExporterConf = { name, conf, serviceOpts }:
|
||||||
|
let
|
||||||
|
enableDynamicUser = serviceOpts.serviceConfig.DynamicUser or true;
|
||||||
|
in
|
||||||
mkIf conf.enable {
|
mkIf conf.enable {
|
||||||
warnings = conf.warnings or [];
|
warnings = conf.warnings or [];
|
||||||
|
users.users = (mkIf (conf.user == "${name}-exporter" && !enableDynamicUser) {
|
||||||
|
"${name}-exporter" = {
|
||||||
|
description = ''
|
||||||
|
Prometheus ${name} exporter service user
|
||||||
|
'';
|
||||||
|
isSystemUser = true;
|
||||||
|
inherit (conf) group;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
users.groups = (mkIf (conf.group == "${name}-exporter" && !enableDynamicUser) {
|
||||||
|
"${name}-exporter" = {};
|
||||||
|
});
|
||||||
networking.firewall.extraCommands = mkIf conf.openFirewall (concatStrings [
|
networking.firewall.extraCommands = mkIf conf.openFirewall (concatStrings [
|
||||||
"ip46tables -A nixos-fw ${conf.firewallFilter} "
|
"ip46tables -A nixos-fw ${conf.firewallFilter} "
|
||||||
"-m comment --comment ${name}-exporter -j nixos-fw-accept"
|
"-m comment --comment ${name}-exporter -j nixos-fw-accept"
|
||||||
@ -139,7 +154,8 @@ let
|
|||||||
serviceConfig.Restart = mkDefault "always";
|
serviceConfig.Restart = mkDefault "always";
|
||||||
serviceConfig.PrivateTmp = mkDefault true;
|
serviceConfig.PrivateTmp = mkDefault true;
|
||||||
serviceConfig.WorkingDirectory = mkDefault /tmp;
|
serviceConfig.WorkingDirectory = mkDefault /tmp;
|
||||||
} serviceOpts ] ++ optional (!(serviceOpts.serviceConfig.DynamicUser or false)) {
|
serviceConfig.DynamicUser = mkDefault enableDynamicUser;
|
||||||
|
} serviceOpts ] ++ optional (!enableDynamicUser) {
|
||||||
serviceConfig.User = conf.user;
|
serviceConfig.User = conf.user;
|
||||||
serviceConfig.Group = conf.group;
|
serviceConfig.Group = conf.group;
|
||||||
});
|
});
|
||||||
|
@ -159,8 +159,10 @@ in
|
|||||||
# `serviceOpts.script` and `serviceOpts.serviceConfig.ExecStart`
|
# `serviceOpts.script` and `serviceOpts.serviceConfig.ExecStart`
|
||||||
# has to be specified here. This will be merged with the default
|
# has to be specified here. This will be merged with the default
|
||||||
# service confiuration.
|
# service confiuration.
|
||||||
|
# Note that by default 'DynamicUser' is 'true'.
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
DynamicUser = false;
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-postfix-exporter}/bin/postfix_exporter \
|
${pkgs.prometheus-postfix-exporter}/bin/postfix_exporter \
|
||||||
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
@ -39,7 +39,6 @@ in
|
|||||||
};
|
};
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-bind-exporter}/bin/bind_exporter \
|
${pkgs.prometheus-bind-exporter}/bin/bind_exporter \
|
||||||
-web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
-web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
@ -18,7 +18,6 @@ in
|
|||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
AmbientCapabilities = [ "CAP_NET_RAW" ]; # for ping probes
|
AmbientCapabilities = [ "CAP_NET_RAW" ]; # for ping probes
|
||||||
DynamicUser = true;
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-blackbox-exporter}/bin/blackbox_exporter \
|
${pkgs.prometheus-blackbox-exporter}/bin/blackbox_exporter \
|
||||||
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
@ -64,7 +64,6 @@ in
|
|||||||
'' else "";
|
'' else "";
|
||||||
in {
|
in {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-collectd-exporter}/bin/collectd_exporter \
|
${pkgs.prometheus-collectd-exporter}/bin/collectd_exporter \
|
||||||
-log.format ${cfg.logFormat} \
|
-log.format ${cfg.logFormat} \
|
||||||
|
@ -26,7 +26,6 @@ in
|
|||||||
};
|
};
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-dnsmasq-exporter}/bin/dnsmasq_exporter \
|
${pkgs.prometheus-dnsmasq-exporter}/bin/dnsmasq_exporter \
|
||||||
--listen ${cfg.listenAddress}:${toString cfg.port} \
|
--listen ${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
@ -39,8 +39,8 @@ in
|
|||||||
mail_plugins = $mail_plugins old_stats
|
mail_plugins = $mail_plugins old_stats
|
||||||
service old-stats {
|
service old-stats {
|
||||||
unix_listener old-stats {
|
unix_listener old-stats {
|
||||||
user = nobody
|
user = dovecot-exporter
|
||||||
group = nobody
|
group = dovecot-exporter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
''';
|
''';
|
||||||
@ -59,6 +59,7 @@ in
|
|||||||
};
|
};
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
DynamicUser = false;
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-dovecot-exporter}/bin/dovecot_exporter \
|
${pkgs.prometheus-dovecot-exporter}/bin/dovecot_exporter \
|
||||||
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
@ -26,7 +26,6 @@ in
|
|||||||
};
|
};
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-fritzbox-exporter}/bin/exporter \
|
${pkgs.prometheus-fritzbox-exporter}/bin/exporter \
|
||||||
-listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
-listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
@ -24,7 +24,6 @@ in
|
|||||||
};
|
};
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-json-exporter}/bin/prometheus-json-exporter \
|
${pkgs.prometheus-json-exporter}/bin/prometheus-json-exporter \
|
||||||
--port ${toString cfg.port} \
|
--port ${toString cfg.port} \
|
||||||
|
@ -143,6 +143,7 @@ in
|
|||||||
};
|
};
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
DynamicUser = false;
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-mail-exporter}/bin/mailexporter \
|
${pkgs.prometheus-mail-exporter}/bin/mailexporter \
|
||||||
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
@ -50,7 +50,6 @@ in
|
|||||||
};
|
};
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-minio-exporter}/bin/minio-exporter \
|
${pkgs.prometheus-minio-exporter}/bin/minio-exporter \
|
||||||
-web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
-web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
@ -34,7 +34,6 @@ in
|
|||||||
};
|
};
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-nginx-exporter}/bin/nginx-prometheus-exporter \
|
${pkgs.prometheus-nginx-exporter}/bin/nginx-prometheus-exporter \
|
||||||
--nginx.scrape-uri '${cfg.scrapeUri}' \
|
--nginx.scrape-uri '${cfg.scrapeUri}' \
|
||||||
|
@ -27,6 +27,7 @@ in
|
|||||||
};
|
};
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
DynamicUser = false;
|
||||||
RuntimeDirectory = "prometheus-node-exporter";
|
RuntimeDirectory = "prometheus-node-exporter";
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-node-exporter}/bin/node_exporter \
|
${pkgs.prometheus-node-exporter}/bin/node_exporter \
|
||||||
|
@ -62,6 +62,7 @@ in
|
|||||||
};
|
};
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
DynamicUser = false;
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-postfix-exporter}/bin/postfix_exporter \
|
${pkgs.prometheus-postfix-exporter}/bin/postfix_exporter \
|
||||||
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
@ -34,6 +34,7 @@ in
|
|||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
environment.DATA_SOURCE_NAME = cfg.dataSourceName;
|
environment.DATA_SOURCE_NAME = cfg.dataSourceName;
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
|
DynamicUser = false;
|
||||||
User = mkIf cfg.runAsLocalSuperUser (mkForce "postgres");
|
User = mkIf cfg.runAsLocalSuperUser (mkForce "postgres");
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-postgres-exporter}/bin/postgres_exporter \
|
${pkgs.prometheus-postgres-exporter}/bin/postgres_exporter \
|
||||||
|
@ -57,7 +57,6 @@ in
|
|||||||
else "${pkgs.writeText "snmp-eporter-conf.yml" (builtins.toJSON cfg.configuration)}";
|
else "${pkgs.writeText "snmp-eporter-conf.yml" (builtins.toJSON cfg.configuration)}";
|
||||||
in {
|
in {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-snmp-exporter.bin}/bin/snmp_exporter \
|
${pkgs.prometheus-snmp-exporter.bin}/bin/snmp_exporter \
|
||||||
--config.file=${configFile} \
|
--config.file=${configFile} \
|
||||||
|
@ -20,7 +20,6 @@ in
|
|||||||
description = "Prometheus exporter for surfboard cable modem";
|
description = "Prometheus exporter for surfboard cable modem";
|
||||||
unitConfig.Documentation = "https://github.com/ipstatic/surfboard_exporter";
|
unitConfig.Documentation = "https://github.com/ipstatic/surfboard_exporter";
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-surfboard-exporter}/bin/surfboard_exporter \
|
${pkgs.prometheus-surfboard-exporter}/bin/surfboard_exporter \
|
||||||
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
@ -26,7 +26,6 @@ in
|
|||||||
};
|
};
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-tor-exporter}/bin/prometheus-tor-exporter \
|
${pkgs.prometheus-tor-exporter}/bin/prometheus-tor-exporter \
|
||||||
-b ${cfg.listenAddress} \
|
-b ${cfg.listenAddress} \
|
||||||
|
@ -51,7 +51,6 @@ in
|
|||||||
};
|
};
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-unifi-exporter}/bin/unifi_exporter \
|
${pkgs.prometheus-unifi-exporter}/bin/unifi_exporter \
|
||||||
-telemetry.addr ${cfg.listenAddress}:${toString cfg.port} \
|
-telemetry.addr ${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
@ -69,6 +69,7 @@ in
|
|||||||
path = [ pkgs.varnish ];
|
path = [ pkgs.varnish ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
RestartSec = mkDefault 1;
|
RestartSec = mkDefault 1;
|
||||||
|
DynamicUser = false;
|
||||||
ExecStart = ''
|
ExecStart = ''
|
||||||
${pkgs.prometheus-varnish-exporter}/bin/prometheus_varnish_exporter \
|
${pkgs.prometheus-varnish-exporter}/bin/prometheus_varnish_exporter \
|
||||||
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
||||||
|
@ -36,19 +36,17 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
serviceOpts = {
|
serviceOpts = {
|
||||||
script = ''
|
|
||||||
${pkgs.prometheus-wireguard-exporter}/bin/prometheus_wireguard_exporter \
|
|
||||||
-p ${toString cfg.port} \
|
|
||||||
${optionalString cfg.verbose "-v"} \
|
|
||||||
${optionalString cfg.singleSubnetPerField "-s"} \
|
|
||||||
${optionalString (cfg.wireguardConfig != null) "-n ${cfg.wireguardConfig}"}
|
|
||||||
'';
|
|
||||||
|
|
||||||
path = [ pkgs.wireguard-tools ];
|
path = [ pkgs.wireguard-tools ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
DynamicUser = true;
|
|
||||||
AmbientCapabilities = [ "CAP_NET_ADMIN" ];
|
AmbientCapabilities = [ "CAP_NET_ADMIN" ];
|
||||||
|
ExecStart = ''
|
||||||
|
${pkgs.prometheus-wireguard-exporter}/bin/prometheus_wireguard_exporter \
|
||||||
|
-p ${toString cfg.port} \
|
||||||
|
${optionalString cfg.verbose "-v"} \
|
||||||
|
${optionalString cfg.singleSubnetPerField "-s"} \
|
||||||
|
${optionalString (cfg.wireguardConfig != null) "-n ${cfg.wireguardConfig}"}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,6 @@ let
|
|||||||
mail = {
|
mail = {
|
||||||
exporterConfig = {
|
exporterConfig = {
|
||||||
enable = true;
|
enable = true;
|
||||||
user = "mailexporter";
|
|
||||||
configuration = {
|
configuration = {
|
||||||
monitoringInterval = "2s";
|
monitoringInterval = "2s";
|
||||||
mailCheckTimeout = "10s";
|
mailCheckTimeout = "10s";
|
||||||
@ -199,9 +198,9 @@ let
|
|||||||
name = "testserver";
|
name = "testserver";
|
||||||
server = "localhost";
|
server = "localhost";
|
||||||
port = 25;
|
port = 25;
|
||||||
from = "mailexporter@localhost";
|
from = "mail-exporter@localhost";
|
||||||
to = "mailexporter@localhost";
|
to = "mail-exporter@localhost";
|
||||||
detectionDir = "/var/spool/mail/mailexporter/new";
|
detectionDir = "/var/spool/mail/mail-exporter/new";
|
||||||
} ];
|
} ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -211,7 +210,7 @@ let
|
|||||||
after = [ "postfix.service" ];
|
after = [ "postfix.service" ];
|
||||||
requires = [ "postfix.service" ];
|
requires = [ "postfix.service" ];
|
||||||
preStart = ''
|
preStart = ''
|
||||||
mkdir -p 0600 mailexporter/new
|
mkdir -p 0600 mail-exporter/new
|
||||||
'';
|
'';
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ProtectHome = true;
|
ProtectHome = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user