> On 16 Jan 2017, at 21:10, Volker Janzen <v...@voja.de> wrote: > > 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 ] > } > } >
Uhm. That’s the first time I see that and I definitely would not recommend to try it that way. You _can’t_ create Zone and Endpoint objects via config sync, you *need* to define them on the client itself prior to establish a connection to between the master and the client. > 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 Yep, that’s correct. It is not allowed to create objects in the context of creating another object. As said, build your endpoint and zone objects on the client itself. I did write some docs to explain that. https://docs.icinga.com/icinga2/latest/doc/module/icinga2/toc#!/icinga2/latest/doc/module/icinga2/chapter/distributed-monitoring#distributed-monitoring-top-down Kind regards, Michael _______________________________________________ icinga-users mailing list icinga-users@lists.icinga.org https://lists.icinga.org/mailman/listinfo/icinga-users