snix/ops/modules/prometheus-fail2ban-exporter.nix
sterni 11681612c3 chore: lib.types.string -> lib.types.str
lib.types.string concatenates conflicting definitions on module merge
which is counter intuitive and hard to debug behavior.

Change-Id: I8ccdca0e8895fb5cc4600c367f8d52a9ab80ff75
Reviewed-on: https://cl.tvl.fyi/c/depot/+/13177
Autosubmit: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Reviewed-by: aspen <root@gws.fyi>
2025-03-02 13:55:21 +00:00

52 lines
1.3 KiB
Nix

{ config, lib, pkgs, depot, ... }:
let
cfg = config.services.prometheus-fail2ban-exporter;
in
{
options.services.prometheus-fail2ban-exporter = with lib; {
enable = mkEnableOption "Prometheus Fail2ban Exporter";
interval = mkOption {
description = "Systemd calendar expression for how often to run the interval";
type = types.str;
default = "minutely";
example = "hourly";
};
};
config = lib.mkIf cfg.enable {
systemd.services."prometheus-fail2ban-exporter" = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" "fail2ban.service" ];
serviceConfig = {
User = "root";
Type = "oneshot";
ExecStart = pkgs.writeShellScript "prometheus-fail2ban-exporter" ''
set -eo pipefail
mkdir -p /var/lib/prometheus/node-exporter
exec prometheus-fail2ban-exporter
'';
};
path = [
pkgs.fail2ban
depot.third_party.prometheus-fail2ban-exporter
];
};
systemd.timers."prometheus-fail2ban-exporter" = {
wantedBy = [ "multi-user.target" ];
timerConfig.OnCalendar = cfg.interval;
};
services.prometheus.exporters.node = {
enabledCollectors = [ "textfile" ];
extraFlags = [
"--collector.textfile.directory=/var/lib/prometheus/node-exporter"
];
};
};
}