i found out that groups assinged via templates overwrite each other.
For example: I have 3 templates which assinging hostgroups to a host.
only the 3rd group will be assigned to the host.
all other groups will be overwridden.
How can i fix this?
Do i understand the concept of hostgroups wrong?
Viper
There are several (long lasting) bug reports for this issue on the Icinga Director issue tracker, one example:
I’m not really sure whether the underlying problem is the Icinga 2 core itself or just the Icinga Director.
For now you have to work around this by assigning the host groups based on, e.g., variables, host names, ip addresses/subnets or add them manually.
The problem is with the handling of the additive assignments. I’m not sure how this can be solved in the Director, but the DSL requires certain tricks as well.
Here’s an example which just overrides everything.
If you want to solve this by using array#add, this works just for groups in this specific case. This is because of the config compiler already knowing that groups is of the array type.
This method does not work with custom variables of the array type. This needs a manual initialization with an empty array, e.g. vars.services = [].
With using the trick of additive assignments solving
uninitialized array being initialized and adding the new value
given array, just adding the new element
this may work. But still, I’m not sure how the Director logic is implemented and how complicated changes could be incorporated to render this differently.