Service apply object - multiple vars in the global template


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.


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

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:

Here is more information on Apply For rules:

I want to define some “vars” on the object apply definition itself. For example, if I want to define a process check service with “vars” for the process names.

There may be a way someone else can share, but you could also consider a Service Set with individual Services for each process name you want to monitor.