Icinga / icingaweb2-module-director

The Director aims to be your new favourite Icinga config deployment tool. Director is designed for those who want to automate their configuration deployment and those who want to grant their “point & click” users easy access to the configuration.
https://icinga.com/docs/director/latest
GNU General Public License v2.0
413 stars 202 forks source link

Template with functions #1168

Closed avik78 closed 4 years ago

avik78 commented 7 years ago

Hi, I'm trying to implement this automated fashion of generation geolocations from host-objects.

https://www.icinga.com/2017/08/16/integrate-maps-into-icinga/

I cant find a way to set this in a template in Director

template Host "geo-host" {
  var loc = getHostGeoLocation(name)

  if (loc) {
    vars.geolocation = loc
  }
}

It work fine when using files, but I want a Director-only setup. I can live with the constants in files (from the above example in the website, but that would be great to have in Director to "have it all"

Thanks, Ole

Context

Your Environment

Thomas-Gelf commented 7 years ago

@avik78: no need to build it that complicated when working with Icinga Director. Just create a related data list with the key being your location and the city as it's label - all done.

avik78 commented 7 years ago

Thanks - was a nice tip.

But - we also use the Automation in Director and we import 3000 AD-objects where there is a naming context for 180 locations in use already on how the objects are named.

Another way is of course to run a script towards AD to set it as an AD-attribute, but we also have some objects we add manually directly into Director.

So if I could use this example to automatically populate vars.geolocation from object name (coming from AD or manual objects) - that would be awesome.

Thomas-Gelf commented 7 years ago

@avik78: use import Property Modifier. Choose a "Regular Expression based Replacement" to extract your location shortcut, write it to a new target column. Next, apply a "Map" modifier to that target column and look up that location shortcut in the chosen Data List. Please note that for this task you must probably flip key and label in your list. You can of course also automate the import of the data list itself.

Thomas-Gelf commented 4 years ago

Closing this old issue, got no feedback. The proposed solution should work fine