server.pp 3.2 KB

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