From 62d52826021431b2008fb16153ea0bc5f17a325f Mon Sep 17 00:00:00 2001 From: aszlig Date: Thu, 13 Jun 2013 02:40:46 +0200 Subject: [PATCH] zabbix-server: Make it easier to use peer auth. Quoting from the manual about DBHost: ``` In case of MySQL localhost or empty string results in using a socket. In case of PostgreSQL only empty string results in attempt to use socket. ``` https://www.zabbix.com/documentation/2.0/manual/appendix/config/zabbix_server With this commit we should avoid some race conditions in systemd, because if the host is set to "", there is no condition that postgresql has to be started prior to the Zabbix server. Signed-off-by: aszlig --- modules/services/monitoring/zabbix-server.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/services/monitoring/zabbix-server.nix b/modules/services/monitoring/zabbix-server.nix index 806aaf4f90a..60c1f914fb7 100644 --- a/modules/services/monitoring/zabbix-server.nix +++ b/modules/services/monitoring/zabbix-server.nix @@ -34,6 +34,8 @@ let ''} ''; + useLocalPostgres = cfg.dbServer == "localhost" || cfg.dbServer == ""; + in { @@ -51,7 +53,10 @@ in services.zabbixServer.dbServer = mkOption { default = "localhost"; - description = "Hostname or IP address of the database server."; + description = '' + Hostname or IP address of the database server. + Use an empty string ("") to use peer authentication. + ''; }; services.zabbixServer.dbPassword = mkOption { @@ -65,7 +70,7 @@ in config = mkIf cfg.enable { - services.postgresql.enable = cfg.dbServer == "localhost"; + services.postgresql.enable = useLocalPostgres; users.extraUsers = singleton { name = "zabbix"; @@ -77,7 +82,7 @@ in { description = "Zabbix Server"; wantedBy = [ "multi-user.target" ]; - after = optional (cfg.dbServer == "localhost") "postgresql.service"; + after = optional useLocalPostgres "postgresql.service"; preStart = ''