10RUPTiV
(10RUPTiV)
November 26, 2019, 6:09pm
1
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”
}
rsturm
(Robert Sturm)
November 26, 2019, 6:43pm
2
Use a hosttemplate:
template Host "linux-box" {
vars.os = "Linux"
}
object Host "hostname" {
import "linux-box"
}
10RUPTiV
(10RUPTiV)
November 26, 2019, 6:46pm
3
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
dnsmichi
(Michael Friedrich)
November 27, 2019, 8:12am
6
Or you have these facts populated from Puppet/Ansible generating the host objects.
10RUPTiV
(10RUPTiV)
November 27, 2019, 12:15pm
7
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!