dependency.pp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # == Defined type: icinga2::object::dependency
  2. #
  3. # This is a defined type for Icinga 2 dependency objects.
  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-dependency
  6. #
  7. # === Parameters
  8. #
  9. # See the inline comments.
  10. #
  11. define icinga2::object::dependency (
  12. $object_name = $name,
  13. $display_name = $name,
  14. $parent_host_name = $host_name,
  15. $parent_service_name = undef,
  16. $child_host_name = undef,
  17. $child_service_name = undef,
  18. $disable_checks = undef,
  19. $disable_notifications = undef,
  20. $period = undef,
  21. $states = [],
  22. $target_dir = '/etc/icinga2/conf.d',
  23. $target_file_name = "${name}.conf",
  24. $target_file_ensure = file,
  25. $target_file_owner = 'root',
  26. $target_file_group = 'root',
  27. $target_file_mode = '0644',
  28. $refresh_icinga2_service = true
  29. ) {
  30. # Do some validation of the class' parameters:
  31. validate_string($object_name)
  32. validate_string($display_name)
  33. validate_string($host_name)
  34. validate_string($parent_host_name)
  35. validate_string($child_host_name)
  36. validate_string($child_service_name)
  37. validate_string($parent_service_name)
  38. # validate_bool($disable_checks)
  39. # validate_bool($disable_notifications)
  40. validate_string($period)
  41. validate_array($states)
  42. validate_string($target_dir)
  43. validate_string($target_file_name)
  44. validate_string($target_file_owner)
  45. validate_string($target_file_group)
  46. validate_string($target_file_mode)
  47. validate_bool($refresh_icinga2_service)
  48. #If the refresh_icinga2_service parameter is set to true...
  49. if $refresh_icinga2_service == true {
  50. file { "${target_dir}/${target_file_name}":
  51. ensure => $target_file_ensure,
  52. owner => $target_file_owner,
  53. group => $target_file_group,
  54. mode => $target_file_mode,
  55. content => template('icinga2/object_dependency.conf.erb'),
  56. #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
  57. notify => Service['icinga2'],
  58. }
  59. }
  60. #...otherwise, use the same file resource but without a notify => parameter:
  61. else {
  62. file { "${target_dir}/${target_file_name}":
  63. ensure => $target_file_ensure,
  64. owner => $target_file_owner,
  65. group => $target_file_group,
  66. mode => $target_file_mode,
  67. content => template('icinga2/object_dependency.conf.erb'),
  68. }
  69. }
  70. }