livestatuslistener.pp 2.5 KB

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