apply_dependency.pp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # == Defined type: icinga2::object::apply_dependency
  2. #
  3. # This is a defined type for Icinga 2 apply 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::apply_dependency (
  12. $object_name = $name,
  13. $display_name = $name,
  14. $object_type = 'Host',
  15. $parent_host_name = undef,
  16. $parent_service_name = undef,
  17. $child_host_name = undef,
  18. $child_service_name = undef,
  19. $disable_checks = undef,
  20. $disable_notifications = undef,
  21. $period = undef,
  22. $states = [],
  23. $assign_where = undef,
  24. $ignore_where = undef,
  25. $target_dir = '/etc/icinga2/conf.d',
  26. $target_file_name = "${name}.conf",
  27. $target_file_owner = 'root',
  28. $target_file_group = 'root',
  29. $target_file_mode = '0644') {
  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_re($object_type, ['^Host', '^Service'])
  48. file { "${target_dir}/${target_file_name}":
  49. ensure => file,
  50. owner => $target_file_owner,
  51. group => $target_file_group,
  52. mode => $target_file_mode,
  53. content => template('icinga2/object_apply_dependency.conf.erb'),
  54. notify => Service['icinga2'],
  55. }
  56. }