graphitewriter.pp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # == Defined type: icinga2::object::graphitewriter
  2. #
  3. # This is a defined type for Icinga 2 GraphiteWriter 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-graphitewriter
  6. #
  7. # === Parameters
  8. #
  9. # See the inline comments.
  10. #
  11. define icinga2::object::graphitewriter (
  12. $graphite_host = '127.0.0.1',
  13. $graphite_port = 2003,
  14. #Put the object files this defined type generates in features-available
  15. #since the Graphite writer feature is one that has to be explicitly enabled.
  16. $target_dir = '/etc/icinga2/features-available',
  17. $target_file_name = "${name}.conf",
  18. $target_file_ensure = file,
  19. $target_file_owner = 'root',
  20. $target_file_group = 'root',
  21. $target_file_mode = '0644',
  22. $refresh_icinga2_service = true
  23. ) {
  24. #Do some validation
  25. validate_string($host)
  26. validate_bool($refresh_icinga2_service)
  27. #If the refresh_icinga2_service parameter is set to true...
  28. if $refresh_icinga2_service == true {
  29. file { "${target_dir}/${target_file_name}":
  30. ensure => $target_file_ensure,
  31. owner => $target_file_owner,
  32. group => $target_file_group,
  33. mode => $target_file_mode,
  34. content => template('icinga2/object_graphitewriter.conf.erb'),
  35. #...notify the Icinga 2 daemon so it can restart and pick up changes made to this config file...
  36. notify => Service['icinga2'],
  37. }
  38. }
  39. #...otherwise, use the same file resource but without a notify => parameter:
  40. else {
  41. file { "${target_dir}/${target_file_name}":
  42. ensure => $target_file_ensure,
  43. owner => $target_file_owner,
  44. group => $target_file_group,
  45. mode => $target_file_mode,
  46. content => template('icinga2/object_graphitewriter.conf.erb'),
  47. }
  48. }
  49. }