IcingaConfig: allow to override vars for dynamic...

...host-crafted services
This commit is contained in:
Thomas Gelf 2016-06-17 20:06:58 +02:00
parent c5811fe055
commit 93e4cc9b5b

View File

@ -414,25 +414,35 @@ class IcingaConfig
return ''; return '';
} }
$varname = $this->getMagicApplyVarName();
return sprintf( return sprintf(
' '
apply Service for (title => params in host.vars["%s"]) { 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 { } else {
import title import title
} }
if (typeof(params["vars"]) == Dictionary) { if (typeof(params.vars) == Dictionary) {
vars += params vars += params
} }
if (typeof(override.vars) == Dictionary) {
vars += override.vars
}
if (typeof(params["host_name"]) == String) { if (typeof(params["host_name"]) == String) {
host_name = params["host_name"] host_name = params["host_name"]
} }
} }
', ',
$this->getMagicApplyVarName() $varname,
$varname
); );
} }