diff --git a/manifests/checkplugin.pp b/manifests/checkplugin.pp index d0e9ef3..ce32298 100644 --- a/manifests/checkplugin.pp +++ b/manifests/checkplugin.pp @@ -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', + } } }