allow either source or content to be used as the file distribution method

Signed-off-by: Nick Chappell <nick@intronic.org>
This commit is contained in:
Steven Bambling 2014-10-05 00:47:51 -04:00 committed by Nick Chappell
parent 5e82839bb1
commit f437b8406f

View file

@ -4,12 +4,14 @@
#
#
define icinga2::checkplugin (
$checkplugin_name = $name,
$checkplugin_libdir = $icinga2::params::checkplugin_libdir,
$checkplugin_target_file_owner = 'root',
$checkplugin_target_file_group = 'root',
$checkplugin_target_file_mode = '0755',
$checkplugin_template = undef,
$checkplugin_name = $name,
$checkplugin_libdir = $icinga2::params::checkplugin_libdir,
$checkplugin_target_file_owner = 'root',
$checkplugin_target_file_group = 'root',
$checkplugin_target_file_mode = '0755',
$checkplugin_file_distribution_method = 'content',
$checkplugin_template = undef,
$checkplugin_source_file = undef,
) {
#Do some validation of the class' parameters:
@ -20,12 +22,28 @@ define icinga2::checkplugin (
validate_string($checkplugin_target_file_group)
validate_string($checkplugin_target_file_mode)
file { "${checkplugin_libdir}/${checkplugin_name}":
owner => $checkplugin_target_file_owner,
group => $checkplugin_target_file_group,
mode => $checkplugin_target_file_mode,
content => template("icinga2/${checkplugin_template}"),
require => Package[$icinga2::params::icinga2_client_packages],
if $checkplugin_file_distribution_method == 'content' {
file { "${checkplugin_libdir}/${checkplugin_name}":
owner => $checkplugin_target_file_owner,
group => $checkplugin_target_file_group,
mode => $checkplugin_target_file_mode,
content => template("icinga2/${checkplugin_template}"),
require => Package[$icinga2::params::icinga2_client_packages],
}
}
elsif $checkplugin_file_distribution_method == 'source' {
file { "${checkplugin_libdir}/${checkplugin_name}":
owner => $checkplugin_target_file_owner,
group => $checkplugin_target_file_group,
mode => $checkplugin_target_file_mode,
source => $checkplugin_source_file,
require => Package[$icinga2::params::icinga2_client_packages],
}
}
else {
notify {'Missing/Incorrect File Distribution Method':
message => 'The parameter checkplugin_file_distribution_method is missing or incorrect. Please set content or source',
}
}
}