Hi Kevin, thet's exactly what I want to do. I understand it in icinga configuration files, but in director I can't do it.
In the service apply rule, there is a menu "Apply For" with this description:
Evaluates the apply for rule for all objects with the custom attribute specified. E.g selecting "host.vars.custom_attr" will generate "for (config in host.vars.array_var)" where "config" will be accessible through "$config$". NOTE: only custom variables of type "Array" are eligible.
It was empty, so I added the field to the host template, and now I can select it.
This is the service apply rule config:
apply Service "check-disk-linux" for (config in host.vars.disks) {
import "check-disk-linux"
assign where "Servers-Linux" in host.groups
import DirectorOverrideTemplate
}
But now when I deploy I get this error:
critical/config: Error: Dictionary iterator requires value to be a dictionary.
Location: in /etc/icinga2/conf.d/services.conf: 65:1-65:53
/etc/icinga2/conf.d/services.conf(63): }
/etc/icinga2/conf.d/services.conf(64):
/etc/icinga2/conf.d/services.conf(65): apply Service for (disk => config in host.vars.disks) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/conf.d/services.conf(66): import "generic-service"
/etc/icinga2/conf.d/services.conf(67):
(0) Evaluating 'apply' rule (in /etc/icinga2/conf.d/services.conf: 65:1-65:53)
(1) Evaluating 'apply' rules for host 'cloudlinux1'