Apply services with custom import


Right now we are having a bunch of “Services” that we create using the “apply” method. BUT right now, we are having different Apply for the SAME services 'cause of some little difference…

So right now I have

apply Service "Processor" {
  import "client1-generic-service"
  import "nrpe-generic-service"
  import "client1-service-override-24x7"

  check_command = "nrpe"

  vars.nrpe_command = "check_cpu"

  assign where host.vars.os == "Windows" && host.vars.nrpe == true && == "client1-zone"

This snippet works perfectly but we need to have a bunch of time to change the first and third import and also the assign for the!

Is there an easy way I can do some something to have only ONE apply Service “Processor” but that will react differently based on the ?

In this example, maybe we are doing it wrong, but the import service-override-24x7 only override the
check_period = “24x7”


What about this approach:

if ( == "client1-zone") {
   import "client1-service-override-24x7"
} else if ( == "client2-zone") {
   import "client2-service-override-24x7"
1 Like