On Tuesday 17 January 2017 at 16:03:42, Mathieu Arnold wrote:

> I am wondering if there could be a way to get the zone and endpoint
> generated somehow.

Yes, there is.

> I then tried another approach, using a for loop, something like:
> 
> for (z in zones) {
>   object Endpoint z {}
>   object Zone z {
>     endpoints = [ z ]
>     parent = "master"
>   }
> }

Close, but there's a weird trick you have to add to Icinga's config language 
when using variables in loops like this: "use".

The following works for me:

for ( server in [ "black", "dechau", "dorn", "dunkel", "durif", "herold", 
"mert", "zin" ] ) {
        object Endpoint server+".example.com" use(server) { host = 
server+".example.com" }
        object Zone server use(server) {
                endpoints = [ server+".example.com" ]
                parent = "Master"
        }
}


Hope that helps,


Antony.

-- 
Programming is a Dark Art, and it will always be. The programmer is
fighting against the two most destructive forces in the universe:
entropy and human stupidity. They're not things you can always
overcome with a "methodology" or on a schedule.

 - Damian Conway, Perl God

                                                   Please reply to the list;
                                                         please *don't* CC me.
_______________________________________________
icinga-users mailing list
icinga-users@lists.icinga.org
https://lists.icinga.org/mailman/listinfo/icinga-users

Reply via email to