endpoint.pp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # == Defined type: icinga2::object::endpoint
  2. #
  3. # This is a defined type for Icinga 2 apply objects that create EndPoint
  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-endpoint
  6. #
  7. # === Parameters
  8. #
  9. # See the inline comments.
  10. #
  11. define icinga2::object::endpoint (
  12. $ensure = 'file',
  13. $object_name = $name,
  14. $host = undef,
  15. $port = undef,
  16. $log_duration = undef,
  17. $target_dir = '/etc/icinga2/objects/endpoints',
  18. $target_file_name = "${name}.conf",
  19. $target_file_owner = 'root',
  20. $target_file_group = 'root',
  21. $target_file_mode = '0644'
  22. ) {
  23. validate_string($host)
  24. if $port {
  25. validate_re($port, '^\d{1,5}$')
  26. }
  27. if $log_duration {
  28. validate_string($log_duration)
  29. }
  30. validate_string($target_dir)
  31. validate_string($target_file_name)
  32. validate_string($target_file_owner)
  33. validate_string($target_file_group)
  34. validate_re($target_file_mode, '^\d{4}$')
  35. file {"${target_dir}/${target_file_name}":
  36. ensure => $ensure,
  37. owner => $target_file_owner,
  38. group => $target_file_group,
  39. mode => $target_file_mode,
  40. content => template('icinga2/object_endpoint.conf.erb'),
  41. notify => Service['icinga2'],
  42. }
  43. }