Adding multiple hosts to multiple groups in one step via parameterized assignments

I am new to Icinga2 and Director and am not sure what I’d like to do is even possible. We have a large number of sites with multiple hosts per site. Via import from our current network monitoring platform we have all the hosts added to Icinga, along with a site-specific hostgroup for each site. What I would like to do now is set up an assign rule that assigns all the imported hosts to the correct site-specific hostgroups in one step, rather than setting up a separate assign rule for each site-specific hostgroup. Alternatively, I would be happy if there were a way to create a parameterized assign “template” that I could apply to all the site-specific hostgroups that would pull values specific to each hostgroup assignment. Is this possible, or is there another way to accomplish the same goal?

Use custom variables for assignment of services or groups when importing hosts to Icinga via Director.
i.e. the variables “location” and “hosttype”.

Set location to SiteA, SiteB,…
Set hosttype to WebSrv, DBSrv,…

Use apply rules that assign services, hostgroups, etc. with criteria host.vars.location = SiteA or host.vars.hosttype=WebSrv,…
See also Director Documention

Additionally you can assign different templates within sync rules by adding templates to hosts based on filter rules in property setting. Filter criteria field must be accessible/part of import data source.

1 Like

Thanks! That did it for me.