conf.pp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # = Define: icinga2::conf
  2. #
  3. # General Apache define to be used to create generic custom .conf files
  4. # Very simple wrapper to a normal file type
  5. # Use source or template to define the source
  6. #
  7. # == Parameters
  8. #
  9. # [*source*]
  10. # Sets the content of source parameter for the dotconf file
  11. # If defined, icinga2 dotconf file will have the param: source => $source
  12. #
  13. # [*template*]
  14. # Sets the path to the template to use as content for dotconf file
  15. # If defined, icinga2 dotconf file has: content => content("$template")
  16. # Note source and template parameters are mutually exclusive: don't use both
  17. #
  18. # [*options_hash*]
  19. # Custom hash with key values to use in custom templates
  20. #
  21. define icinga2::conf (
  22. $source = '' ,
  23. $template = '' ,
  24. $options_hash = undef,
  25. $ensure = present,
  26. $target_dir = '/etc/icinga2/conf.d',
  27. $target_file_name = "${name}.conf",
  28. $target_file_owner = 'root',
  29. $target_file_group = 'root',
  30. $target_file_mode = '644'
  31. ) {
  32. validate_string($target_dir)
  33. validate_string($target_file_name)
  34. validate_string($target_file_owner)
  35. validate_string($target_file_group)
  36. validate_string($target_file_mode)
  37. $manage_file_source = $source ? {
  38. '' => undef,
  39. default => $source,
  40. }
  41. $manage_file_content = $template ? {
  42. '' => undef,
  43. default => template($template),
  44. }
  45. file { "${target_dir}/${target_file_name}":
  46. ensure => $ensure,
  47. owner => $target_file_owner,
  48. group => $target_file_group,
  49. mode => $target_file_mode,
  50. notify => Service['icinga2'],
  51. source => $manage_file_source,
  52. content => $manage_file_content,
  53. }
  54. }