mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 07:01:54 +00:00
nixos/zabbixServer: replace extraConfig option with settings option
This commit is contained in:
parent
970b2b853d
commit
3aa68faa78
@ -5,8 +5,9 @@ let
|
|||||||
pgsql = config.services.postgresql;
|
pgsql = config.services.postgresql;
|
||||||
mysql = config.services.mysql;
|
mysql = config.services.mysql;
|
||||||
|
|
||||||
inherit (lib) mkDefault mkEnableOption mkIf mkOption;
|
inherit (lib) mkDefault mkEnableOption mkIf mkMerge mkOption;
|
||||||
inherit (lib) attrValues concatMapStringsSep literalExample optional optionalAttrs optionalString types;
|
inherit (lib) attrValues concatMapStringsSep literalExample optional optionalAttrs optionalString types;
|
||||||
|
inherit (lib.generators) toKeyValue;
|
||||||
|
|
||||||
user = "zabbix";
|
user = "zabbix";
|
||||||
group = "zabbix";
|
group = "zabbix";
|
||||||
@ -19,24 +20,7 @@ let
|
|||||||
paths = attrValues cfg.modules;
|
paths = attrValues cfg.modules;
|
||||||
};
|
};
|
||||||
|
|
||||||
configFile = pkgs.writeText "zabbix_server.conf" ''
|
configFile = pkgs.writeText "zabbix_server.conf" (toKeyValue { listsAsDuplicateKeys = true; } cfg.settings);
|
||||||
LogType = console
|
|
||||||
ListenIP = ${cfg.listen.ip}
|
|
||||||
ListenPort = ${toString cfg.listen.port}
|
|
||||||
# TODO: set to cfg.database.socket if database type is pgsql?
|
|
||||||
DBHost = ${optionalString (cfg.database.createLocally != true) cfg.database.host}
|
|
||||||
${optionalString (cfg.database.createLocally != true) "DBPort = ${cfg.database.port}"}
|
|
||||||
DBName = ${cfg.database.name}
|
|
||||||
DBUser = ${cfg.database.user}
|
|
||||||
${optionalString (cfg.database.passwordFile != null) "Include ${passwordFile}"}
|
|
||||||
${optionalString (mysqlLocal && cfg.database.socket != null) "DBSocket = ${cfg.database.socket}"}
|
|
||||||
PidFile = ${runtimeDir}/zabbix_server.pid
|
|
||||||
SocketDir = ${runtimeDir}
|
|
||||||
FpingLocation = /run/wrappers/bin/fping
|
|
||||||
${optionalString (cfg.modules != {}) "LoadModulePath = ${moduleEnv}/lib"}
|
|
||||||
${concatMapStringsSep "\n" (name: "LoadModule = ${name}") (builtins.attrNames cfg.modules)}
|
|
||||||
${cfg.extraConfig}
|
|
||||||
'';
|
|
||||||
|
|
||||||
mysqlLocal = cfg.database.createLocally && cfg.database.type == "mysql";
|
mysqlLocal = cfg.database.createLocally && cfg.database.type == "mysql";
|
||||||
pgsqlLocal = cfg.database.createLocally && cfg.database.type == "pgsql";
|
pgsqlLocal = cfg.database.createLocally && cfg.database.type == "pgsql";
|
||||||
@ -47,6 +31,7 @@ in
|
|||||||
imports = [
|
imports = [
|
||||||
(lib.mkRenamedOptionModule [ "services" "zabbixServer" "dbServer" ] [ "services" "zabbixServer" "database" "host" ])
|
(lib.mkRenamedOptionModule [ "services" "zabbixServer" "dbServer" ] [ "services" "zabbixServer" "database" "host" ])
|
||||||
(lib.mkRemovedOptionModule [ "services" "zabbixServer" "dbPassword" ] "Use services.zabbixServer.database.passwordFile instead.")
|
(lib.mkRemovedOptionModule [ "services" "zabbixServer" "dbPassword" ] "Use services.zabbixServer.database.passwordFile instead.")
|
||||||
|
(lib.mkRemovedOptionModule [ "services" "zabbixServer" "extraConfig" ] "Use services.zabbixServer.settings instead.")
|
||||||
];
|
];
|
||||||
|
|
||||||
# interface
|
# interface
|
||||||
@ -176,15 +161,19 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
# TODO: for bonus points migrate this to https://github.com/NixOS/rfcs/pull/42
|
settings = mkOption {
|
||||||
extraConfig = mkOption {
|
type = with types; attrsOf (oneOf [ int str (listOf str) ]);
|
||||||
default = "";
|
default = {};
|
||||||
type = types.lines;
|
|
||||||
description = ''
|
description = ''
|
||||||
Configuration that is injected verbatim into the configuration file. Refer to
|
Zabbix Server configuration. Refer to
|
||||||
<link xlink:href="https://www.zabbix.com/documentation/current/manual/appendix/config/zabbix_server"/>
|
<link xlink:href="https://www.zabbix.com/documentation/current/manual/appendix/config/zabbix_server"/>
|
||||||
for details on supported values.
|
for details on supported values.
|
||||||
'';
|
'';
|
||||||
|
example = {
|
||||||
|
CacheSize = "1G";
|
||||||
|
SSHKeyLocation = "/var/lib/zabbix/.ssh";
|
||||||
|
StartPingers = 32;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -204,6 +193,26 @@ in
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
services.zabbixServer.settings = mkMerge [
|
||||||
|
{
|
||||||
|
LogType = "console";
|
||||||
|
ListenIP = cfg.listen.ip;
|
||||||
|
ListenPort = cfg.listen.port;
|
||||||
|
# TODO: set to cfg.database.socket if database type is pgsql?
|
||||||
|
DBHost = optionalString (cfg.database.createLocally != true) cfg.database.host;
|
||||||
|
DBName = cfg.database.name;
|
||||||
|
DBUser = cfg.database.user;
|
||||||
|
PidFile = "${runtimeDir}/zabbix_server.pid";
|
||||||
|
SocketDir = runtimeDir;
|
||||||
|
FpingLocation = "/run/wrappers/bin/fping";
|
||||||
|
LoadModule = builtins.attrNames cfg.modules;
|
||||||
|
}
|
||||||
|
(mkIf (cfg.database.createLocally != true) { DBPort = cfg.database.port; })
|
||||||
|
(mkIf (cfg.database.passwordFile != null) { Include = [ "${passwordFile}" ]; })
|
||||||
|
(mkIf (mysqlLocal && cfg.database.socket != null) { DBSocket = cfg.database.socket; })
|
||||||
|
(mkIf (cfg.modules != {}) { LoadModulePath = "${moduleEnv}/lib"; })
|
||||||
|
];
|
||||||
|
|
||||||
networking.firewall = mkIf cfg.openFirewall {
|
networking.firewall = mkIf cfg.openFirewall {
|
||||||
allowedTCPPorts = [ cfg.listen.port ];
|
allowedTCPPorts = [ cfg.listen.port ];
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user