nixos/zabbixAgent: replace extraConfig option with settings option
This commit is contained in:
parent
3aa68faa78
commit
b58e0905d0
@ -3,8 +3,9 @@
|
|||||||
let
|
let
|
||||||
cfg = config.services.zabbixAgent;
|
cfg = config.services.zabbixAgent;
|
||||||
|
|
||||||
inherit (lib) mkDefault mkEnableOption mkIf mkOption;
|
inherit (lib) mkDefault mkEnableOption mkIf mkMerge mkOption;
|
||||||
inherit (lib) attrValues concatMapStringsSep literalExample optionalString types;
|
inherit (lib) attrValues concatMapStringsSep literalExample optionalString types;
|
||||||
|
inherit (lib.generators) toKeyValue;
|
||||||
|
|
||||||
user = "zabbix-agent";
|
user = "zabbix-agent";
|
||||||
group = "zabbix-agent";
|
group = "zabbix-agent";
|
||||||
@ -14,19 +15,15 @@ let
|
|||||||
paths = attrValues cfg.modules;
|
paths = attrValues cfg.modules;
|
||||||
};
|
};
|
||||||
|
|
||||||
configFile = pkgs.writeText "zabbix_agent.conf" ''
|
configFile = pkgs.writeText "zabbix_agent.conf" (toKeyValue { listsAsDuplicateKeys = true; } cfg.settings);
|
||||||
LogType = console
|
|
||||||
Server = ${cfg.server}
|
|
||||||
ListenIP = ${cfg.listen.ip}
|
|
||||||
ListenPort = ${toString cfg.listen.port}
|
|
||||||
${optionalString (cfg.modules != {}) "LoadModulePath = ${moduleEnv}/lib"}
|
|
||||||
${concatMapStringsSep "\n" (name: "LoadModule = ${name}") (builtins.attrNames cfg.modules)}
|
|
||||||
${cfg.extraConfig}
|
|
||||||
'';
|
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
imports = [
|
||||||
|
(lib.mkRemovedOptionModule [ "services" "zabbixAgent" "extraConfig" ] "Use services.zabbixAgent.settings instead.")
|
||||||
|
];
|
||||||
|
|
||||||
# interface
|
# interface
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
@ -105,15 +102,18 @@ 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 Agent configuration. Refer to
|
||||||
<link xlink:href="https://www.zabbix.com/documentation/current/manual/appendix/config/zabbix_agentd"/>
|
<link xlink:href="https://www.zabbix.com/documentation/current/manual/appendix/config/zabbix_agentd"/>
|
||||||
for details on supported values.
|
for details on supported values.
|
||||||
'';
|
'';
|
||||||
|
example = {
|
||||||
|
Hostname = "example.org";
|
||||||
|
DebugLevel = 4;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -124,6 +124,17 @@ in
|
|||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
|
services.zabbixAgent.settings = mkMerge [
|
||||||
|
{
|
||||||
|
LogType = "console";
|
||||||
|
Server = cfg.server;
|
||||||
|
ListenIP = cfg.listen.ip;
|
||||||
|
ListenPort = cfg.listen.port;
|
||||||
|
LoadModule = builtins.attrNames cfg.modules;
|
||||||
|
}
|
||||||
|
(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