diff --git a/library/Director/IcingaConfig/IcingaConfig.php b/library/Director/IcingaConfig/IcingaConfig.php index d06f5d0e..4fb425e8 100644 --- a/library/Director/IcingaConfig/IcingaConfig.php +++ b/library/Director/IcingaConfig/IcingaConfig.php @@ -470,9 +470,10 @@ class IcingaConfig return sprintf( ' -const DirectorVarsOverride = "%s" +const DirectorOverrideVars = "%s" +const DirectorOverrideTemplate = "%s" -template Service "%s" { +template Service DirectorOverrideTemplate { /** * Seems that host is missing when used in a service object, works fine for * apply rules @@ -482,9 +483,9 @@ template Service "%s" { } if (vars) { - vars += host.vars[DirectorVarsOverride][name] + vars += host.vars[DirectorOverrideVars][name] } else { - vars = host.vars[DirectorVarsOverride][name] + vars = host.vars[DirectorOverrideVars][name] } } ', @@ -523,12 +524,11 @@ apply Service for (title => params in host.vars["%s"]) { host_name = params["host_name"] } - import "%s" + import DirectorOverrideTemplate } ', $varname, - $varname, - $this->connection->settings()->override_services_templatename + $varname ); } diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php index 7e746b11..cd28b361 100644 --- a/library/Director/Objects/IcingaService.php +++ b/library/Director/Objects/IcingaService.php @@ -166,7 +166,7 @@ class IcingaService extends IcingaObject protected function renderSuffix() { - if ($this->isApplyRule()) { + if ($this->isApplyRule() || $this->usesVarOverrides()) { return $this->renderImportHostVarOverrides() . parent::renderSuffix(); } else { return parent::renderSuffix(); @@ -181,10 +181,7 @@ class IcingaService extends IcingaObject ); } - return sprintf( - "\n import \"%s\"\n", - $this->connection->settings()->override_services_templatename - ); + return "\n import DirectorOverrideTemplate\n"; } protected function renderCustomExtensions()