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

_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to