i have a service definition that uses a nest of if else statements which is picked up correctly in the service object BUT the command object does not honor the values as arguments.
service.conf:
vars.hface = if ( host.vars.version == "2.x" ) {
["em1","em2","p3p1","p3p2"]
} else if ( "core-hosts" in host.groups ) {
["em1","em2","em3"]
} else if (!( "core-hosts" in host.groups )) {
["em1","p1p2"]
} else {
["em1","em2"]
}
doing an “inspect” - the service shows the vars as correct but the actual command line does not use these values. i’ve tried several things including bouncing the satellites as well as the masters but to no avail.
we have an HA master-satellite cluster running version: r2.11.2-1
has anyone else experienced a similar situation where command is not using arguments from the service definition?
it’s not the issue with the logic in the service definition - the vars from the service are not being using by the command definition. for example, a host that’s not version 2.x and has core-hosts in it’s host.group has [“em1”,“em2”,“em3”] in the list of service vars - but the command line is using [“em1”,“p1p2”]. clearly something is missing between service and command.
right - the “modified” is from the service conf file - which i would expect since those are/should be correct; but the command is using the “else” value.
some further testing today reversing the “if” statement has incorrect values in the service object. could there be an issue where the conditional test is treating true as a string instead of a boolean?
@homerjay - how did you resolve the var being overwritten?
oh here’s something unusual - on the master the vars.grouping which has the host.groups are correct so the service object should be correct BUT on the satellites they’re incorrect.
master:
* vars
* grouping = [ "all-hypervisor", "so1-hosts", "core-hosts" ]
% = modified in '/etc/icinga2/zones.d/satellite-so1/services-hypervisor.conf', lines 26:3-26:29
satellites:
* vars
* grouping = [ ]
% = modified in '/var/lib/icinga2/api/zones/satellite-so1/_etc/services-hypervisor.conf', lines 26:3-26:29
can you diff the files from master and satellite? I think your satellite does not get all informations needed. Maybe the variable is defined is filled in a other zone then the satellite has access to it.