1 { config, lib, pkgs, ... }:
6 cfg = config.services.elasticsearch-curator;
7 curatorConfig = pkgs.writeTextFile {
11 # Remember, leave a key empty if there is no value. None will be a string,
12 # not a Python "NoneType"
14 hosts: ${builtins.toJSON cfg.hosts}
15 port: ${toString cfg.port}
21 ssl_no_validate: False
29 blacklist: ['elasticsearch', 'urllib3']
32 curatorAction = pkgs.writeTextFile {
34 text = cfg.actionYAML;
38 options.services.elasticsearch-curator = {
40 enable = mkEnableOption (lib.mdDoc "elasticsearch curator");
42 description = lib.mdDoc "The frequency to run curator, a systemd.time such as 'hourly'";
47 description = lib.mdDoc "a list of elasticsearch hosts to connect to";
48 type = types.listOf types.str;
49 default = ["localhost"];
52 description = lib.mdDoc "the port that elasticsearch is listening on";
56 actionYAML = mkOption {
57 description = lib.mdDoc "curator action.yaml file contents, alternatively use curator-cli which takes a simple action command";
63 action: delete_indices
65 Delete indices older than 45 days (based on index name), for logstash-
66 prefixed indices. Ignore the error if the filter does not result in an
67 actionable list of indices (ignore_empty_list) and exit cleanly.
69 ignore_empty_list: True
78 timestring: '%Y.%m.%d'
85 config = mkIf cfg.enable {
86 systemd.services.elasticsearch-curator = {
87 startAt = cfg.interval;
90 "${pkgs.elasticsearch-curator}/bin/curator" +
91 " --config ${curatorConfig} ${curatorAction}";