Apply variable to host

Hey guys…

Is there a way to apply custom variables to HOST using the same kind of apply for services ?

I would like to do something like:

apply Host {
vars.os = “Linux”
vars.customers = “???”
vars.customer_contacts = [ “???” ]
vars.geolocation = “???”

vars.parents = [ “???” ]

assign where host.address && host.vars.agent == true && host.zone == “zoneName”

}

Use a hosttemplate:

template Host "linux-box" {
  vars.os = "Linux"
}
object Host "hostname" {
  import "linux-box"
}

Already have a bunch of host template… but instead of “import” a template, I would like something more like “assign where…”

That is not possible. What is your intention behind an “apply host”?

You can script that and modify the host objects via director api (never tested) or directly via icinga api.
Just get first a list with the objects you want to modify and then modify them one by one via api.

1 Like

Or you have these facts populated from Puppet/Ansible generating the host objects.

The idea behind that, it’s to apply some custom variable that we will use somewhere but generated based on something.

Let say we could apply some variable like
vars.customers = “???”
vars.customer_contacts = [ “???” ]
vars.geolocation = “???”

vars.parents = [ “???” ]

Based on where host.zone == “zone1”

But I think we will play with host template!