host.pp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # == Defined type: icinga2::object::host
  2. #
  3. # This is a defined type for Icinga 2 host 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-host
  6. #
  7. # === Parameters
  8. #
  9. # See the inline comments.
  10. #
  11. define icinga2::object::host (
  12. $object_hostname = $name,
  13. $display_name = $fqdn,
  14. $ipv4_address = $ipaddress_eth0,
  15. $ipv6_address = undef,
  16. $template_to_import = 'generic-host',
  17. $groups = [],
  18. $vars = {},
  19. $check_command = undef,
  20. $max_check_attempts = undef,
  21. $check_period = undef,
  22. $check_interval = undef,
  23. $retry_interval = undef,
  24. $enable_notifications = undef,
  25. $enable_active_checks = undef,
  26. $enable_passive_checks = undef,
  27. $enable_event_handler = undef,
  28. $enable_flap_detection = undef,
  29. $enable_perfdata = undef,
  30. $event_command = undef,
  31. #flapping_threshold is defined as a percentage, eg. 10%, 50%, etc.
  32. $flapping_threshold = undef,
  33. $volatile = undef,
  34. $notes = undef,
  35. $notes_url = undef,
  36. $action_url = undef,
  37. $icon_image = undef,
  38. $icon_image_alt = undef,
  39. $target_dir = '/etc/icinga2/conf.d',
  40. $target_file_name = "${fqdn}.conf",
  41. $target_file_owner = 'root',
  42. $target_file_group = 'root',
  43. $target_file_mode = '644'
  44. ) {
  45. #Do some validation of the class' parameters:
  46. validate_string($object_hostname)
  47. validate_string($template_to_import)
  48. validate_string($display_name)
  49. validate_string($ipv4_address)
  50. validate_array($groups)
  51. validate_hash($vars)
  52. validate_string($target_dir)
  53. validate_string($target_file_name)
  54. validate_string($target_file_owner)
  55. validate_string($target_file_group)
  56. validate_string($target_file_mode)
  57. file {"${target_dir}/${target_file_name}":
  58. ensure => file,
  59. owner => $target_file_owner,
  60. group => $target_file_group,
  61. mode => $target_file_mode,
  62. content => template('icinga2/object_host.conf.erb'),
  63. notify => Service['icinga2'],
  64. }
  65. }