From 93e4cc9b5b14bbd098d1fc650d9edbada5674a15 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 17 Jun 2016 20:06:58 +0200 Subject: [PATCH] IcingaConfig: allow to override vars for dynamic... ...host-crafted services --- library/Director/IcingaConfig/IcingaConfig.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/library/Director/IcingaConfig/IcingaConfig.php b/library/Director/IcingaConfig/IcingaConfig.php index 08715268..8b26bfc7 100644 --- a/library/Director/IcingaConfig/IcingaConfig.php +++ b/library/Director/IcingaConfig/IcingaConfig.php @@ -414,25 +414,35 @@ class IcingaConfig return ''; } + $varname = $this->getMagicApplyVarName(); + return sprintf( ' apply Service for (title => params in host.vars["%s"]) { - if (typeof(params["imports"]) in [Array, String]) { - import params["imports"] + + override = host.vars["%s_vars"][title] + + if (typeof(params["templates"]) in [Array, String]) { + import params["templates"] } else { import title } - if (typeof(params["vars"]) == Dictionary) { + if (typeof(params.vars) == Dictionary) { vars += params } + if (typeof(override.vars) == Dictionary) { + vars += override.vars + } + if (typeof(params["host_name"]) == String) { host_name = params["host_name"] } } ', - $this->getMagicApplyVarName() + $varname, + $varname ); }