Apply rules for hosts, mixing Director and static files


Using icinga + Director last versions, and though I read this, I found the answer was quite short.

The logic of my setup is as such : I’m trying to set up the most disposable configuration in the world, having absolutely everything created from automation (hosts, services…) and keeping nothing defined statically.
For that, I’m using modules that allow me to import and created hosts objects on the fly, and regularly delete the all - they get re-created some times later.
I’m using import modules like vspheredb, proxmox pve, x509, netbox, and they are all helping me to create the needed objects.

Now, it looks like I reached the end of what I can automate, and I now need to add some specific variables to this volatile hosts (host.vars.custom01 = 42).
I could manually add these vars after the hosts are created (web gui, REST API…), but obviously, I would need to manually repeat this action.

For the services objects, I’m using service apply rules, thus nothing has to be done manually.
For the hosts objects, there seem to be no similar mean.

I was thinking about writing the needed host.vars declarations in a static file, but I guess they will collide with what Director will produce and the known universe will obviously collapse or worse : the icinga daemon will refuse to restart.

May some of you have any comments about the collapsing universe?

Hello @nec!

Sounds like you want this:


on_config_committed {
  get_host("foobar").vars.custom01 = 42

But meanwhile you could define:

template Host default {
  if ( == "foo") { = 42

  if ( != "foo") { = 23



Hello Alex (@Al2Klimov ),

That sounds very interesting, and opening amazing perspectives.
Thanks for pointing me to that feature.

Just to be sure about your last advice, about managing the “default” template : is this a reserved word (“default”) which I can use to supersede what’s behind, or should I manually take care of the inheritance of this default template towards my existing templates?


Yes, default is a magic keyword. All hosts would inherit a such template.