checkplugin.pp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. require => Package[$icinga2::params::icinga2_client_packages],
  32. }
  33. }
  34. elsif $checkplugin_file_distribution_method == 'source' {
  35. file { "${checkplugin_libdir}/${checkplugin_name}":
  36. owner => $checkplugin_target_file_owner,
  37. group => $checkplugin_target_file_group,
  38. mode => $checkplugin_target_file_mode,
  39. source => $checkplugin_source_file,
  40. require => Package[$icinga2::params::icinga2_client_packages],
  41. }
  42. }
  43. elsif $checkplugin_file_distribution_method == 'inline' {
  44. file { "${checkplugin_libdir}/${checkplugin_name}":
  45. owner => $checkplugin_target_file_owner,
  46. group => $checkplugin_target_file_group,
  47. mode => $checkplugin_target_file_mode,
  48. content => $checkplugin_source_inline,
  49. require => Package[$icinga2::params::icinga2_client_packages],
  50. }
  51. }
  52. else {
  53. notify {'Missing/Incorrect File Distribution Method':
  54. message => 'The parameter checkplugin_file_distribution_method is missing or incorrect. Please set content or source',
  55. }
  56. }
  57. }