statusdatawriter.pp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # == Defined type: icinga2::object::statusdatawriter
  2. #
  3. # This is a defined type for Icinga 2 apply objects that create StatusDataWriter
  4. # See the following Icinga 2 doc page for more info:
  5. # http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-statusdatawriter
  6. #
  7. # === Parameters
  8. #
  9. # See the inline comments.
  10. #
  11. define icinga2::object::statusdatawriter (
  12. $object_statusdatawritername = $name,
  13. $status_path = undef,
  14. $objects_path = undef,
  15. $update_interval = undef,
  16. $target_dir = '/etc/icinga2/objects/statusdatawriters',
  17. $target_file_name = "${name}.conf",
  18. $target_file_ensure = file,
  19. $target_file_owner = 'root',
  20. $target_file_group = 'root',
  21. $target_file_mode = '0644',
  22. $refresh_icinga2_service = true
  23. ) {
  24. #Do some validation of the class' parameters:
  25. if $object_statusdatawritername {
  26. validate_string($object_statusdatawritername)
  27. }
  28. if $status_path {
  29. validate_string($status_path)
  30. }
  31. if $objects_path {
  32. validate_string($objects_path)
  33. }
  34. if $update_interval {
  35. validate_string($update_interval)
  36. }
  37. validate_string($target_dir)
  38. validate_string($target_file_name)
  39. validate_string($target_file_owner)
  40. validate_string($target_file_group)
  41. validate_re($target_file_mode, '^\d{4}$')
  42. validate_bool($refresh_icinga2_service)
  43. #If the refresh_icinga2_service parameter is set to true...
  44. if $refresh_icinga2_service == true {
  45. file { "${target_dir}/${target_file_name}":
  46. ensure => $target_file_ensure,
  47. owner => $target_file_owner,
  48. group => $target_file_group,
  49. mode => $target_file_mode,
  50. content => template('icinga2/object_statusdatawriter.conf.erb'),
  51. #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
  52. notify => Service['icinga2'],
  53. }
  54. }
  55. #...otherwise, use the same file resource but without a notify => parameter:
  56. else {
  57. file { "${target_dir}/${target_file_name}":
  58. ensure => $target_file_ensure,
  59. owner => $target_file_owner,
  60. group => $target_file_group,
  61. mode => $target_file_mode,
  62. content => template('icinga2/object_statusdatawriter.conf.erb'),
  63. }
  64. }
  65. }