added default value to arguments, env and vars and moved check to the template.
Signed-off-by: Nick Chappell <nick@intronic.org> Merged in from: https://github.com/Icinga/puppet-icinga2/pull/33 refs#7215: https://dev.icinga.org/issues/7215
This commit is contained in:
parent
60e5a294f8
commit
4dfe6fa664
2 changed files with 11 additions and 17 deletions
|
@ -15,9 +15,9 @@ define icinga2::object::eventcommand (
|
|||
/* $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/eventcommands',
|
||||
$target_file_name = "${name}.conf",
|
||||
|
@ -31,15 +31,9 @@ define icinga2::object::eventcommand (
|
|||
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+$')
|
||||
}
|
||||
|
|
|
@ -15,14 +15,14 @@ object EventCommand "<%= @object_eventcommandname %>" {
|
|||
|
||||
<%- 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 EventCommand "<%= @object_eventcommandname %>" {
|
|||
<%- end -%>
|
||||
}
|
||||
<%- end -%>
|
||||
<%- if @vars.empty? -%>
|
||||
|
||||
<%- if @vars -%>
|
||||
<%- @vars.each_pair do |key,value| -%>
|
||||
<%= key %> = <% if value.class == String %><%= value %>
|
||||
<%- else -%>{
|
||||
|
@ -47,12 +47,12 @@ object EventCommand "<%= @object_eventcommandname %>" {
|
|||
<%- end -%>
|
||||
<%- end -%>
|
||||
<%- end -%>
|
||||
|
||||
<%- if @timeout -%>
|
||||
|
||||
timeout = <%= @timeout %>
|
||||
<%- end -%>
|
||||
<%- if @env.empty? != true -%>
|
||||
|
||||
<%- if @env -%>
|
||||
env = {
|
||||
<%- @env.each_pair do |key,value| -%>
|
||||
<%= key %> = <%= value %>
|
||||
|
|
Loading…
Reference in a new issue