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 */
|
/* $methods = undef, */ /* Need to get more details about this attribute */
|
||||||
$command = undef,
|
$command = undef,
|
||||||
$cmd_path = 'PluginDir',
|
$cmd_path = 'PluginDir',
|
||||||
$arguments = undef,
|
$arguments = {},
|
||||||
$env = undef,
|
$env = {},
|
||||||
$vars = undef,
|
$vars = {},
|
||||||
$timeout = undef,
|
$timeout = undef,
|
||||||
$target_dir = '/etc/icinga2/objects/eventcommands',
|
$target_dir = '/etc/icinga2/objects/eventcommands',
|
||||||
$target_file_name = "${name}.conf",
|
$target_file_name = "${name}.conf",
|
||||||
|
@ -31,15 +31,9 @@ define icinga2::object::eventcommand (
|
||||||
validate_string($template_to_import)
|
validate_string($template_to_import)
|
||||||
validate_array($command)
|
validate_array($command)
|
||||||
validate_string($cmd_path)
|
validate_string($cmd_path)
|
||||||
if $arguments {
|
validate_hash($arguments)
|
||||||
validate_hash($arguments)
|
validate_hash($env)
|
||||||
}
|
validate_hash($vars)
|
||||||
if $env {
|
|
||||||
validate_hash($env)
|
|
||||||
}
|
|
||||||
if $vars {
|
|
||||||
validate_hash($vars)
|
|
||||||
}
|
|
||||||
if $timeout {
|
if $timeout {
|
||||||
validate_re($timeout, '^\d+$')
|
validate_re($timeout, '^\d+$')
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,14 +15,14 @@ object EventCommand "<%= @object_eventcommandname %>" {
|
||||||
|
|
||||||
<%- if @template_to_import -%>
|
<%- if @template_to_import -%>
|
||||||
import "<%= @template_to_import -%>"
|
import "<%= @template_to_import -%>"
|
||||||
|
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<%- if @command -%>
|
<%- if @command -%>
|
||||||
|
|
||||||
command = [ <% if @cmd_path -%><%= @cmd_path -%> + <% end -%><% @command.each_with_index do |cmd, i| %><%= cmd -%><%= ', ' if i < (@command.size - 1) %><% end %> ]
|
command = [ <% if @cmd_path -%><%= @cmd_path -%> + <% end -%><% @command.each_with_index do |cmd, i| %><%= cmd -%><%= ', ' if i < (@command.size - 1) %><% end %> ]
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<%#- Need to add support to argument value as hash (recursivity) -%>
|
<%#- Need to add support to argument value as hash (recursivity) -%>
|
||||||
|
<%- if @arguments.empty? != true -%>
|
||||||
|
|
||||||
<%- if @arguments -%>
|
|
||||||
arguments = {
|
arguments = {
|
||||||
<%- @arguments.each_with_index do |(key,value), i| -%>
|
<%- @arguments.each_with_index do |(key,value), i| -%>
|
||||||
<%= key %> = <% if value.class == String %><%= value %>
|
<%= key %> = <% if value.class == String %><%= value %>
|
||||||
|
@ -35,8 +35,8 @@ object EventCommand "<%= @object_eventcommandname %>" {
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
}
|
}
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
<%- if @vars.empty? -%>
|
||||||
|
|
||||||
<%- if @vars -%>
|
|
||||||
<%- @vars.each_pair do |key,value| -%>
|
<%- @vars.each_pair do |key,value| -%>
|
||||||
<%= key %> = <% if value.class == String %><%= value %>
|
<%= key %> = <% if value.class == String %><%= value %>
|
||||||
<%- else -%>{
|
<%- else -%>{
|
||||||
|
@ -47,12 +47,12 @@ object EventCommand "<%= @object_eventcommandname %>" {
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
|
||||||
<%- if @timeout -%>
|
<%- if @timeout -%>
|
||||||
|
|
||||||
timeout = <%= @timeout %>
|
timeout = <%= @timeout %>
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
<%- if @env.empty? != true -%>
|
||||||
|
|
||||||
<%- if @env -%>
|
|
||||||
env = {
|
env = {
|
||||||
<%- @env.each_pair do |key,value| -%>
|
<%- @env.each_pair do |key,value| -%>
|
||||||
<%= key %> = <%= value %>
|
<%= key %> = <%= value %>
|
||||||
|
|
Loading…
Reference in a new issue