server.pp 2.3 KB

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