[icinga-users] Create Endpoint & Zone for each host

Volker Janzen voja at voja.de
Mon Jan 16 21:10:01 CET 2017


Hi,

I like to simplify adding new hosts to my top-down config sync setup. Currently, I need to add Endpoint & Zone entries for each host to my zones.conf file by hand.

I found a config snippet that suggested to add a host template like this:

/etc/icinga2/zones.d/global-templates/generic-agent.conf

template Host "generic-agent" {
 import "generic-host"

 object Endpoint __name {
   host = "$host.address$"
 }

 object Zone __name {
   parent = "master"
   endpoints = [ __name ]
 }
}

A new host should then get only a host defition: /etc/icinga2/zones.d/child/host.conf

object Host "child" {
       import "generic-agent"
       check_command = "hostalive"
       address = ...
       vars.os = "Linux"
       zone = "master"
}

When I check this configuration changes, Icinga2 shows this error:

critical/config: Error: Error while evaluating expression: Objects may not be created outside of an activation context.
Location: in /etc/icinga2/zones.d/global-templates/generic-agent.conf: 4:3-4:24
/etc/icinga2/zones.d/global-templates/generic-agent.conf(2):   import "generic-host"
/etc/icinga2/zones.d/global-templates/generic-agent.conf(3):
/etc/icinga2/zones.d/global-templates/generic-agent.conf(4):   object Endpoint __name {
                                                              ^^^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/zones.d/global-templates/generic-agent.conf(5):     host = "$host.address$"
/etc/icinga2/zones.d/global-templates/generic-agent.conf(6):   }

critical/config: 1 error

I'm not sure what this error message means and how I could fix this error to achieve what I explained above.


Regards,
    Volker

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.icinga.org/pipermail/icinga-users/attachments/20170116/6ed655c0/attachment.html>


More information about the icinga-users mailing list