server.pp 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. ) inherits icinga2::params {
  29. #Do some validation of parameters so we know we have the right data types:
  30. validate_bool($manage_repos)
  31. validate_bool($use_debmon_repo)
  32. validate_string($server_db_type)
  33. validate_string($db_name)
  34. validate_string($db_user)
  35. validate_string($db_password)
  36. validate_string($db_host)
  37. validate_string($db_port)
  38. validate_string($package_provider)
  39. validate_string($icinga2_server_package)
  40. validate_bool($server_install_nagios_plugins)
  41. #Pick set the right path where we can find the DB schema based on the OS...
  42. case $::operatingsystem {
  43. 'CentOS': {
  44. #...and database that the user picks
  45. case $server_db_type {
  46. 'mysql': { $server_db_schema_path = '/usr/share/icinga2-ido-mysql/schema/mysql.sql' }
  47. 'pgsql': { $server_db_schema_path = '/usr/share/icinga2-ido-pgsql/schema/pgsql.sql' }
  48. default: { fail("${server_db_type} is not a supported database! Please specify either 'mysql' for MySQL or 'pgsql' for Postgres.") }
  49. }
  50. }
  51. #Ubuntu systems:
  52. 'Ubuntu': {
  53. #Pick set the right path where we can find the DB schema
  54. case $server_db_type {
  55. 'mysql': { $server_db_schema_path = '/usr/share/icinga2-ido-mysql/schema/mysql.sql' }
  56. 'pgsql': { $server_db_schema_path = '/usr/share/icinga2-ido-pgsql/schema/pgsql.sql' }
  57. default: { fail("${server_db_type} is not a supported database! Please specify either 'mysql' for MySQL or 'pgsql' for Postgres.") }
  58. }
  59. }
  60. #Debian systems:
  61. 'Debian': {
  62. #Pick set the right path where we can find the DB schema
  63. case $server_db_type {
  64. 'mysql': { $server_db_schema_path = '/usr/share/icinga2-ido-mysql/schema/mysql.sql' }
  65. 'pgsql': { $server_db_schema_path = '/usr/share/icinga2-ido-pgsql/schema/pgsql.sql' }
  66. default: { fail("${server_db_type} is not a supported database! Please specify either 'mysql' for MySQL or 'pgsql' for Postgres.") }
  67. }
  68. }
  69. #Fail if we're on any other OS:
  70. default: { fail("${::operatingsystem} is not supported!") }
  71. }
  72. #Apply our classes in the right order. Use the squiggly arrows (~>) to ensure that the
  73. #class left is applied before the class on the right and that it also refreshes the
  74. #class on the right.
  75. class {'icinga2::server::install':} ~>
  76. class {'icinga2::server::config':} ~>
  77. class {'icinga2::server::features':
  78. enabled_features => $server_enabled_features,
  79. disabled_features => $server_disabled_features,
  80. } ~>
  81. class {'icinga2::server::service':}
  82. }