System configuration for OpenStack Infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

grafana.pp 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # == Class: openstack_project::grafana
  2. #
  3. # === Parameters
  4. # [*cfg*]
  5. # Manages the Grafana configuration file. The upstream puppet-grafana module
  6. # documentaion: https://github.com/bfraser/puppet-grafana#cfg
  7. #
  8. class openstack_project::grafana (
  9. $mysql_password,
  10. $admin_password = '',
  11. $admin_user = 'admin',
  12. $grafana_cfg = {},
  13. $http_host = '127.0.0.1',
  14. $http_port = '8080',
  15. $mysql_host = '127.0.0.1',
  16. $mysql_name = 'grafana',
  17. $mysql_user = 'grafana',
  18. $project_config_repo = '',
  19. $secret_key = '',
  20. $vhost_name = $::fqdn,
  21. ) {
  22. include ::httpd
  23. $grafana_cfg_defaults = {
  24. # NOTE(pabelanger): app_mode must be the first key!
  25. 'app_mode' => 'production',
  26. 'analytics' => {
  27. 'reporting_enabled' => false,
  28. },
  29. 'auth.anonymous' => {
  30. enabled => true,
  31. },
  32. 'database' => {
  33. type => 'mysql',
  34. host => "${mysql_host}:3306",
  35. name => $mysql_name,
  36. user => $mysql_user,
  37. password => $mysql_password,
  38. },
  39. 'security' => {
  40. admin_password => $admin_password,
  41. admin_user => $admin_user,
  42. secret_key => $secret_key,
  43. },
  44. 'server' => {
  45. http_addr => $http_host,
  46. http_port => $http_port,
  47. },
  48. 'users' => {
  49. allow_sign_up => false,
  50. },
  51. }
  52. $grafana_cfg_merged = merge($grafana_cfg_defaults, $grafana_cfg)
  53. class { '::grafana':
  54. cfg => $grafana_cfg_merged,
  55. # Note that we can't use archive because that install_method requires
  56. # the camptocamp-archive module but we have puppetcommunity-archive
  57. # in modules.env, and puppet only supports having one in the modulepath
  58. # at a time.
  59. install_method => 'repo',
  60. version => '2.1.0',
  61. }
  62. ::httpd::vhost { $vhost_name:
  63. docroot => 'MEANINGLESS ARGUMENT',
  64. port => 80,
  65. priority => '50',
  66. template => 'openstack_project/grafana.vhost.erb',
  67. }
  68. httpd_mod { 'rewrite':
  69. ensure => present,
  70. }
  71. httpd_mod { 'proxy':
  72. ensure => present,
  73. }
  74. httpd_mod { 'proxy_http':
  75. ensure => present,
  76. }
  77. class { '::project_config':
  78. url => $project_config_repo,
  79. }
  80. class { '::grafyaml':
  81. config_dir => $::project_config::grafana_dashboards_dir,
  82. grafana_url => "http://${admin_user}:${admin_password}@${http_host}:${http_port}",
  83. require => Class['grafana'],
  84. }
  85. }