idopgsqlconnection.pp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # == Defined type: icinga2::object::idopgsqlconnection
  2. #
  3. # This is a defined type for Icinga 2 IDO Postgres connection 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-idopgsqlconnection
  6. #
  7. # === Parameters
  8. #
  9. # See the inline comments.
  10. #
  11. define icinga2::object::idopgsqlconnection (
  12. $object_name = $name,
  13. $host = '127.0.0.1',
  14. $port = 5432,
  15. $user = 'icinga',
  16. $password = 'icinga',
  17. $database = 'icinga',
  18. $table_prefix = 'icinga_',
  19. $instance_name = 'default',
  20. $instance_description = undef,
  21. $cleanup = {
  22. acknowledgements_age => 0,
  23. commenthistory_age => 0,
  24. contactnotifications_age => 0,
  25. contactnotificationmethods_age => 0,
  26. downtimehistory_age => 0,
  27. eventhandlers_age => 0,
  28. externalcommands_age => 0,
  29. flappinghistory_age => 0,
  30. hostchecks_age => 0,
  31. logentries_age => 0,
  32. notifications_age => 0,
  33. processevents_age => 0,
  34. statehistory_age => 0,
  35. servicechecks_age => 0,
  36. systemcommands_age => 0
  37. },
  38. $categories = [],
  39. $target_dir = '/etc/icinga2/conf.d',
  40. $target_file_name = "${name}.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_name)
  47. validate_string($template_to_import)
  48. validate_string($host)
  49. validate_string($user)
  50. validate_string($password)
  51. validate_string($database)
  52. validate_string($table_prefix)
  53. validate_string($instance_name)
  54. validate_hash($cleanup)
  55. validate_array($categories)
  56. validate_string($target_dir)
  57. validate_string($target_file_name)
  58. validate_string($target_file_owner)
  59. validate_string($target_file_group)
  60. validate_string($target_file_mode)
  61. file {"${target_dir}/${target_file_name}":
  62. ensure => file,
  63. owner => $target_file_owner,
  64. group => $target_file_group,
  65. mode => $target_file_mode,
  66. content => template('icinga2/object_idopgsqlconnection.conf.erb'),
  67. notify => Service['icinga2'],
  68. }
  69. }