Set an host variable from an HostGroup object

Hello !

I’ve tried something for the past three days and it seems I’m not good enough. I want to set the same “icon_image” variable to all my group members but I don’t know where to set it .

I’v tried this :

object HostGroup "Linux" {
   display_name = "Linux"
   host.vars.icon_image = "img/icons/Linux.png"
   assign where "Linux" in host.groups
}

But the attribute host does not exist for group Object.

I also tried a loop in my group object :

for (host in get_objects(Host)) {
  if (host.groups == "Linux") {
    host.icon_image = "path_to_the_image"
  }

And there is no error but nothing is display and the icon object for my host still empty.

Thank you in advance for your help !

You cannot define host options via host groups. You could use host templates instead and add appropriate template to desired host objects.