Icinga / chef-icinga2

Icinga 2 Chef Cookbook
https://supermarket.chef.io/cookbooks/icinga2
Apache License 2.0
41 stars 55 forks source link

[dev.icinga.com #11031] Syntax error: Times parameter does not accept double apostrophe. #194

Closed icinga-migration closed 7 years ago

icinga-migration commented 8 years ago

This issue has been migrated from Redmine: https://dev.icinga.com/issues/11031

Created by vncntvandriessche on 2016-01-25 17:07:31 +00:00

Assignee: vkhatri Status: Assigned Target Version: (none) Last Update: 2016-04-17 07:42:55 +00:00 (in Redmine)


I ran into this problem trying to configure the "times"-parameter inside of an

icinga2_applynotification

resource.

The problem is that the templates for both "applynotifications" and notification invokes the ruby "#inspect" function on the value of the hash provided in the resource:

  <%- if options['times'] && !options['times'].empty? -%>
  times = {
  <% options['times'].each do |var, value| %>
    <% if var && value -%>
    <%= var %> = <%= value.inspect %>
    <%- end -%>
  <%- end -%>
  }
  <%- end -%>

More context: here:

This generates an incorrect file, similar to the following snippet:

apply Notification "escalation_sms_service" to Service {
  import "notification-sms-template-service"
  times = {
    begin = "30m"
    end = "1h"
  }
  user_groups = ["my_user_group"]
  assign where true
}
[...]

(same error is found for the

icinga2_notification

resource)

Resulting in a failure upon reloading the icinga2 daemon:

service icinga2 reload

root@default-wheezy:/etc/icinga2/objects.d# tail /var/log/icinga2/startup.log
/etc/icinga2/objects.d/applynotification.conf(19):     begin = "30m"
                                                   ^^^^^^^^^^^^^^^^^
/etc/icinga2/objects.d/applynotification.conf(20):     end = "1h"
                                                   ^^^^^^^^^^^^^^
/etc/icinga2/objects.d/applynotification.conf(21):   }
                                                   ^^^
/etc/icinga2/objects.d/applynotification.conf(22):   user_groups = ["my_user_group"]
/etc/icinga2/objects.d/applynotification.conf(23):   assign where true

critical/config: 366 errors

You can fix it by removing the "-character around the values for the hash-keys in the config:

apply Notification "escalation_sms3_sms4_service" to Service {
  import "notification-sms-template-service"
  times = {
    begin = 30m
    end = 1h
  }
  user_groups = ["openminds"]
  assign where true
}

service icinga2 reload

root@default-wheezy:/etc/icinga2/objects.d# tail /var/log/icinga2/startup.log
[...]
information/cli: Finished validating the configuration file(s).

(Happy startup.log)

More information on the parameter can be found here: http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc\#!/icinga2/latest/doc/module/icinga2/chapter/monitoring-basics#notifications.

I have made a Merge Request to fix this issue here: https://github.com/Icinga/chef-icinga2/pull/45

icinga-migration commented 8 years ago

Updated by vkhatri on 2016-04-17 07:42:56 +00:00

vkhatri commented 7 years ago

PR Merged.