checkplugin.pp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # == Defined Type: icinga2::checkplugin
  2. #
  3. # === Parameters
  4. #
  5. #
  6. define icinga2::checkplugin (
  7. $checkplugin_name = $name,
  8. $checkplugin_libdir = $icinga2::params::checkplugin_libdir,
  9. $checkplugin_target_file_owner = 'root',
  10. $checkplugin_target_file_group = 'root',
  11. $checkplugin_target_file_mode = '0755',
  12. $checkplugin_file_distribution_method = 'content',
  13. $checkplugin_template_module = 'icinga2',
  14. $checkplugin_template = undef,
  15. $checkplugin_source_file = undef,
  16. ) {
  17. #Do some validation of the class' parameters:
  18. validate_string($name)
  19. validate_string($checkplugin_libdir)
  20. validate_string($checkplugin_name)
  21. validate_string($checkplugin_target_file_owner)
  22. validate_string($checkplugin_target_file_group)
  23. validate_string($checkplugin_target_file_mode)
  24. if $checkplugin_file_distribution_method == 'content' {
  25. file { "${checkplugin_libdir}/${checkplugin_name}":
  26. owner => $checkplugin_target_file_owner,
  27. group => $checkplugin_target_file_group,
  28. mode => $checkplugin_target_file_mode,
  29. content => template("${checkplugin_template_module}/${checkplugin_template}"),
  30. require => Package[$icinga2::params::icinga2_client_packages],
  31. }
  32. }
  33. elsif $checkplugin_file_distribution_method == 'source' {
  34. file { "${checkplugin_libdir}/${checkplugin_name}":
  35. owner => $checkplugin_target_file_owner,
  36. group => $checkplugin_target_file_group,
  37. mode => $checkplugin_target_file_mode,
  38. source => $checkplugin_source_file,
  39. require => Package[$icinga2::params::icinga2_client_packages],
  40. }
  41. }
  42. else {
  43. notify {'Missing/Incorrect File Distribution Method':
  44. message => 'The parameter checkplugin_file_distribution_method is missing or incorrect. Please set content or source',
  45. }
  46. }
  47. }