server.pp 3.1 KB

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