[icinga-checkins] icinga.org: puppet-icinga2/master: added default value to arguments, env and vars and moved check to the template.

git at icinga.org git at icinga.org
Sun Nov 2 05:40:26 CET 2014


Module: puppet-icinga2
Branch: master
Commit: d55c055682a8bc2fd4589045fdaad8d94a6f6b1e
URL:    https://git.icinga.org/?p=puppet-icinga2.git;a=commit;h=d55c055682a8bc2fd4589045fdaad8d94a6f6b1e

Author: Ricardo Melo <ricardo.melo at gameloft.com>
Date:   Tue Oct 28 17:22:37 2014 -0400

added default value to arguments, env and vars and moved check to the template.

Signed-off-by: Nick Chappell <nick at intronic.org>

Merged in from: https://github.com/Icinga/puppet-icinga2/pull/32

refs#7228: https://dev.icinga.org/issues/7228

---

 manifests/object/notificationcommand.pp       |   18 ++++++------------
 templates/object_notificationcommand.conf.erb |   10 +++++-----
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/manifests/object/notificationcommand.pp b/manifests/object/notificationcommand.pp
index ced2ec5..928ec5f 100644
--- a/manifests/object/notificationcommand.pp
+++ b/manifests/object/notificationcommand.pp
@@ -15,9 +15,9 @@ define icinga2::object::notificationcommand (
 /*  $methods           = undef, */ /* Need to get more details about this attribute */
   $command           = undef,
   $cmd_path          = 'PluginDir',
-  $arguments         = undef,
-  $env               = undef,
-  $vars              = undef,
+  $arguments         = {},
+  $env               = {},
+  $vars              = {},
   $timeout           = undef,
   $target_dir        = '/etc/icinga2/objects/notificationcommands',
   $target_file_name  = "${name}.conf",
@@ -31,15 +31,9 @@ define icinga2::object::notificationcommand (
   validate_string($template_to_import)
   validate_array($command)
   validate_string($cmd_path)
-  if $arguments {
-    validate_hash($arguments)
-  }
-  if $env {
-    validate_hash($env)
-  }
-  if $vars {
-    validate_hash($vars)
-  }
+  validate_hash($arguments)
+  validate_hash($env)
+  validate_hash($vars)
   if $timeout {
     validate_re($timeout, '^\d+$')
   }
diff --git a/templates/object_notificationcommand.conf.erb b/templates/object_notificationcommand.conf.erb
index cb1384b..73fc8af 100644
--- a/templates/object_notificationcommand.conf.erb
+++ b/templates/object_notificationcommand.conf.erb
@@ -15,14 +15,14 @@ object NotificationCommand "<%= @object_notificationcommandname %>" {
 
   <%- if @template_to_import -%>
   import "<%= @template_to_import -%>"
-
   <%- end -%>
   <%- if @command -%>
+
   command = [ <% if @cmd_path -%><%= @cmd_path -%> + <% end -%><% @command.each_with_index do |cmd, i| %><%= cmd -%><%= ', ' if i < (@command.size - 1) %><% end %> ]
   <%- end -%>
   <%#- Need to add support to argument value as hash (recursivity) -%>
+  <%- if @arguments.empty? != true -%>
 
-  <%- if @arguments -%>
   arguments = {
   <%- @arguments.each_with_index do |(key,value), i| -%>
     <%= key %> = <% if value.class == String %><%= value %>
@@ -35,8 +35,8 @@ object NotificationCommand "<%= @object_notificationcommandname %>" {
   <%- end -%>
   }
   <%- end -%>
+  <%- if @vars.empty? != true -%>
 
-  <%- if @vars -%>
   <%- @vars.each_pair do |key,value| -%>
   <%= key %> = <% if value.class == String %><%= value %>
   <%- else -%>{
@@ -47,12 +47,12 @@ object NotificationCommand "<%= @object_notificationcommandname %>" {
     <%- end -%>
   <%- end -%>
   <%- end -%>
-
   <%- if @timeout -%>
+
   timeout = <%= @timeout %>
   <%- end -%>
+  <%- if @env.empty? != true -%>
 
-  <%- if @env -%>
   env = {
   <%- @env.each_pair do |key,value| -%>
     <%= key %> = <%= value %>



More information about the icinga-checkins mailing list