server.pp 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # == Class: icinga2::server
  2. #
  3. # This module installs and configures the server components for the Icinga 2 monitoring system.
  4. #
  5. # === Parameters
  6. #
  7. # Coming soon...
  8. #
  9. # === Examples
  10. #
  11. # Coming soon...
  12. #
  13. class icinga2::server (
  14. $manage_repos = $icinga2::params::manage_repos,
  15. $use_debmon_repo = $icinga2::params::use_debmon_repo,
  16. $server_db_type = $icinga2::params::server_db_type,
  17. $db_name = $icinga2::params::db_name,
  18. $db_user = $icinga2::params::db_user,
  19. $db_password = $icinga2::params::db_password,
  20. $db_host = $icinga2::params::db_host,
  21. $db_port = $icinga2::params::db_port,
  22. $package_provider = $icinga2::params::package_provider,
  23. $icinga2_server_package = $icinga2::params::icinga2_server_package,
  24. $server_install_nagios_plugins = $icinga2::params::server_install_nagios_plugins,
  25. $install_mail_utils_package = $icinga2::params::install_mail_utils_package,
  26. $server_enabled_features = $icinga2::params::server_enabled_features,
  27. $server_disabled_features = $icinga2::params::server_disabled_features,
  28. $purge_unmanaged_object_files = $icinga2::params::purge_unmanaged_object_files
  29. ) inherits icinga2::params {
  30. #Do some validation of parameters so we know we have the right data types:
  31. validate_bool($manage_repos)
  32. validate_bool($use_debmon_repo)
  33. validate_string($server_db_type)
  34. validate_string($db_name)
  35. validate_string($db_user)
  36. validate_string($db_password)
  37. validate_string($db_host)
  38. validate_string($db_port)
  39. validate_string($package_provider)
  40. validate_string($icinga2_server_package)
  41. validate_bool($server_install_nagios_plugins)
  42. #Pick set the right path where we can find the DB schema based on the OS...
  43. case $::operatingsystem {
  44. 'CentOS','RedHat': {
  45. #...and database that the user picks
  46. case $server_db_type {
  47. 'mysql': { $server_db_schema_path = '/usr/share/icinga2-ido-mysql/schema/mysql.sql' }
  48. 'pgsql': { $server_db_schema_path = '/usr/share/icinga2-ido-pgsql/schema/pgsql.sql' }
  49. default: { fail("${server_db_type} is not a supported database! Please specify either 'mysql' for MySQL or 'pgsql' for Postgres.") }
  50. }
  51. }
  52. #Ubuntu systems:
  53. 'Ubuntu': {
  54. #Pick set the right path where we can find the DB schema
  55. case $server_db_type {
  56. 'mysql': { $server_db_schema_path = '/usr/share/icinga2-ido-mysql/schema/mysql.sql' }
  57. 'pgsql': { $server_db_schema_path = '/usr/share/icinga2-ido-pgsql/schema/pgsql.sql' }
  58. default: { fail("${server_db_type} is not a supported database! Please specify either 'mysql' for MySQL or 'pgsql' for Postgres.") }
  59. }
  60. }
  61. #Debian systems:
  62. 'Debian': {
  63. #Pick set the right path where we can find the DB schema
  64. case $server_db_type {
  65. 'mysql': { $server_db_schema_path = '/usr/share/icinga2-ido-mysql/schema/mysql.sql' }
  66. 'pgsql': { $server_db_schema_path = '/usr/share/icinga2-ido-pgsql/schema/pgsql.sql' }
  67. default: { fail("${server_db_type} is not a supported database! Please specify either 'mysql' for MySQL or 'pgsql' for Postgres.") }
  68. }
  69. }
  70. #Fail if we're on any other OS:
  71. default: { fail("${::operatingsystem} is not supported!") }
  72. }
  73. #Apply our classes in the right order. Use the squiggly arrows (~>) to ensure that the
  74. #class left is applied before the class on the right and that it also refreshes the
  75. #class on the right.
  76. class {'icinga2::server::install':} ~>
  77. class {'icinga2::server::config':} ~>
  78. class {'icinga2::server::features':
  79. enabled_features => $server_enabled_features,
  80. disabled_features => $server_disabled_features,
  81. } ~>
  82. class {'icinga2::server::service':}
  83. }