Service apply object - multiple vars in the global template

Hello,

Is it possible to use multiple vars in the service apply definition in a loop ? I don’t want to define those vars at the host level. The respective check commands would be defined for each instance of the var.

Thanks

I guess it is possible. Can anyone share an example if they are using this method?
Thanks

What do you mean in a loop?

Can you give an example of what you’re trying to do?

Here is an example for a somewhat complicated service apply we have – worth noting that it does use host.vars, but might give you an idea of where do go:

If you’re using the director module, here is what the same rule looks like in the director (some of the rule comes from an import and aren’t shown here when compared to the generated config):

If you want to use a for loop, here is an example (Director specific, but they show the config at the end). In the example they apply it for each port in a list of TCP ports:

https://icinga.com/docs/icinga-director/latest/doc/15-Service-apply-for-example/

Here is more information on Apply For rules:
https://icinga.com/docs/icinga-2/latest/doc/03-monitoring-basics/#using-apply-for