checkplugin.pp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. $checkplugin_source_inline = undef,
  17. ) {
  18. #Do some validation of the class' parameters:
  19. validate_string($name)
  20. validate_string($checkplugin_libdir)
  21. validate_string($checkplugin_name)
  22. validate_string($checkplugin_target_file_owner)
  23. validate_string($checkplugin_target_file_group)
  24. validate_string($checkplugin_target_file_mode)
  25. if $checkplugin_file_distribution_method == 'content' {
  26. file { "${checkplugin_libdir}/${checkplugin_name}":
  27. owner => $checkplugin_target_file_owner,
  28. group => $checkplugin_target_file_group,
  29. mode => $checkplugin_target_file_mode,
  30. content => template("${checkplugin_template_module}/${checkplugin_template}"),
  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. }
  40. }
  41. elsif $checkplugin_file_distribution_method == 'inline' {
  42. file { "${checkplugin_libdir}/${checkplugin_name}":
  43. owner => $checkplugin_target_file_owner,
  44. group => $checkplugin_target_file_group,
  45. mode => $checkplugin_target_file_mode,
  46. content => $checkplugin_source_inline,
  47. }
  48. }
  49. else {
  50. notify {'Missing/Incorrect File Distribution Method':
  51. message => 'The parameter checkplugin_file_distribution_method is missing or incorrect. Please set content or source',
  52. }
  53. }
  54. }