Hi,
I’m having troubles with latest Icinga2 release:
[2019-11-13 13:34:20 +0000] critical/config: Error: Error while evaluating expression: Cannot convert value of type 'String' to an object.
Location: in /etc/icinga2/zones.d/global-templates/system.conf: 542:3-542:22
/etc/icinga2/zones.d/global-templates/system.conf(540): check_command = "check_smart_log"
/etc/icinga2/zones.d/global-templates/system.conf(541): command_endpoint = host.name
/etc/icinga2/zones.d/global-templates/system.conf(542): vars = vars + config
^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/zones.d/global-templates/system.conf(543): assign where "physical-servers" in host.groups
/etc/icinga2/zones.d/global-templates/system.conf(544): ignore where !host.vars.client_endpoint || !host.vars.hdd
[2019-11-13 13:34:20 +0000] critical/config: Error: Error while evaluating expression: Cannot convert value of type 'String' to an object.
Location: in /etc/icinga2/zones.d/global-templates/system.conf: 542:3-542:22
/etc/icinga2/zones.d/global-templates/system.conf(540): check_command = "check_smart_log"
/etc/icinga2/zones.d/global-templates/system.conf(541): command_endpoint = host.name
/etc/icinga2/zones.d/global-templates/system.conf(542): vars = vars + config
^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/zones.d/global-templates/system.conf(543): assign where "physical-servers" in host.groups
/etc/icinga2/zones.d/global-templates/system.conf(544): ignore where !host.vars.client_endpoint || !host.vars.hdd
[2019-11-13 13:34:20 +0000] critical/config: 2 errors
[2019-11-13 13:34:20 +0000] critical/cli: Config validation failed. Re-run with 'icinga2 daemon -C' after fixing the config.
the full config looks like this:
apply Service for (disk_name => config in host.vars.hdd) {
import "generic-service"
display_name = "SMART-" + disk_name
check_command = "check_smart_log"
command_endpoint = host.name
vars = vars + config
assign where "physical-servers" in host.groups
ignore where !host.vars.client_endpoint || !host.vars.hdd
}
I haven’t changed anything in configuration, the check used to be valid. Any idea how to debug this? The variable host.vars.hdd is non-empty for all hosts as far as I can tell:
I’ve updated the puppet module to support + config syntax. The error remains basically the same:
[2019-11-13 14:03:31 +0000] critical/config: Error: Error while evaluating expression: Cannot convert value of type 'String' to an object.
Location: in /etc/icinga2/zones.d/global-templates/system.conf: 542:3-542:16
/etc/icinga2/zones.d/global-templates/system.conf(540): check_command = "check_smart_log"
/etc/icinga2/zones.d/global-templates/system.conf(541): command_endpoint = host.name
/etc/icinga2/zones.d/global-templates/system.conf(542): vars += config
^^^^^^^^^^^^^^
/etc/icinga2/zones.d/global-templates/system.conf(543): assign where "physical-servers" in host.groups
/etc/icinga2/zones.d/global-templates/system.conf(544): ignore where !host.vars.client_endpoint
I wish icinga would print on which Host it’s failing, but it’s not showing in icinga daemon -C output. Is there some option to enable more verbose output?
you can use the script debugger within the config validation to halt on errors. At that scope, you can print the object which is affected. Likely you have a host, where vars.hdd has a key with a string value instead of a dictionary.