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

Rendering of Icinga2 global functions #1871

Open jonbulica99 opened 5 years ago

jonbulica99 commented 5 years ago

Expected Behavior

Consider the following rendered configuration:

apply Notification "update_checks_notification" to Service {
    import "mail-notification-service"
    period = "update_checks_period"
    assign where "Update Checks" in service.groups
    vars.customer_email = "{{ get_email_for_zone(service.host_name) }}"
}

I'm basically trying to get the function get_email_for_zone() to be evaluated. For our purposes, assume the function is defined as follows:

globals.get_email_for_zone = function(zone_name) {
    return "user@" + zone_name;
}

Current Behavior

The customer_email variable keeps getting interpreted as a literal string, probably because of the quotation marks the director puts around it.

Possible Solution

Much like the macros functionality, the director should check for the presence of opening {{ and closing }} before deciding whether to use quotation marks or not.

Steps to Reproduce (for bugs)

Define a Notification apply rule for services (probably not limited to Notifications) and try to set a custom property as follows: image You should get a similar rendered config to the one shown above (Expected Behavior).

Your Environment

Punkoivan commented 5 years ago

We also got this with service template - director interpets this like just a string.

jonbulica99 commented 5 years ago

@Thomas-Gelf will you be considering this?