0

I have four device types: apache11, apache12, apache22 and apache24. The first two use password "4597" and the second two use password "9634." All of these webservers have the same admin user, "kingfish."

Here's the logic I thought should work.

apply Service "HTTP/80: Apache Status" {
  import "generic-service"
  check_interval = 10m
  retry_interval = 3m
  check_command = "check-custom-apache"
  vars.gsuser = "kingfish"

    if ( host.vars.devtype == "apache22" || host.vars.devtype == "apache24" ) {
        vars.gspass = "9634"
    } else ( host.vars.devtype == "apache11" || host.vars.devtype == "apache12" ) {
        vars.gspass = "4597"
    }
  assign where host.vars.devtype == "apache22"
  assign where host.vars.devtype == "apache24"
  assign where host.vars.devtype == "apache11"
  assign where host.vars.devtype == "apache12"
}

The error I'm getting is:

critical/config: Error: syntax error, unexpected '(', expecting if (T_IF) or '{'
Location: in /etc/icinga2/zones.d/global-templates/xrs-services.conf: 62:12-62:12
/etc/icinga2/zones.d/global-templates/xrs-services.conf(60):     if ( host.vars.devtype == "apache22" || host.vars.devtype == "apache24" ) {
/etc/icinga2/zones.d/global-templates/xrs-services.conf(61):       vars.gspass = "9634"
/etc/icinga2/zones.d/global-templates/xrs-services.conf(62):     } else ( host.vars.devtype == "apache11" || host.vars.devtype == "apache11" ) {
                                                                        ^
/etc/icinga2/zones.d/global-templates/xrs-services.conf(63):       vars.gspass = "4597"
/etc/icinga2/zones.d/global-templates/xrs-services.conf(64):     }

All I'm trying to accomplish is to use one password for one group of machines and a different one for another group of machines.

mr.zog
  • 902
  • 3
  • 16
  • 36

1 Answers1

0

It's always going to be "else if" following "if"

if ( host.vars.devtype == "apache22" || host.vars.devtype == "apache24" ) {
    vars.gspass = "9634"
} else if ( host.vars.devtype == "apache11" || host.vars.devtype == "apache12" ) {
vars.gspass = "4597"
}
mr.zog
  • 902
  • 3
  • 16
  • 36