graphite.pp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # == Class icingaweb2::mod::graphite
  2. #
  3. class icingaweb2::mod::graphite (
  4. $git_repo = 'https://github.com/philiphoy/icingaweb2-module-graphite.git',
  5. $git_revision = undef,
  6. $graphite_base_url = 'http://graphite.com/render?',
  7. $graphite_metric_prefix = undef,
  8. $service_name_template = undef,
  9. $host_name_template = undef,
  10. $install_method = 'git',
  11. $pkg_deps = undef,
  12. $pkg_ensure = 'present',
  13. $web_root = $::icingaweb2::params::web_root,
  14. ) {
  15. require ::icingaweb2
  16. validate_absolute_path($web_root)
  17. validate_re($install_method,
  18. [
  19. 'git',
  20. ]
  21. )
  22. File {
  23. require => Class['::icingaweb2::config'],
  24. owner => $::icingaweb2::config_user,
  25. group => $::icingaweb2::config_group,
  26. mode => $::icingaweb2::config_file_mode,
  27. }
  28. file {
  29. "${web_root}/modules/graphite":
  30. ensure => directory,
  31. mode => $::icingaweb2::config_dir_mode;
  32. "${::icingaweb2::config_dir}/modules/graphite":
  33. ensure => directory,
  34. mode => $::icingaweb2::config_dir_mode;
  35. }
  36. Ini_Setting {
  37. ensure => present,
  38. require => File["${::icingaweb2::config_dir}/modules/graphite"],
  39. path => "${::icingaweb2::config_dir}/modules/graphite/config.ini",
  40. }
  41. ini_setting { 'base_url':
  42. section => 'graphite',
  43. setting => 'base_url',
  44. value => $graphite_base_url,
  45. }
  46. if $graphite_metric_prefix {
  47. ini_setting { 'metric_prefix':
  48. section => 'graphite',
  49. setting => 'metric_prefix',
  50. value => $graphite_metric_prefix,
  51. }
  52. }
  53. if $service_name_template {
  54. ini_setting { 'service_name_template':
  55. section => 'graphite',
  56. setting => 'service_name_template',
  57. value => $service_name_template,
  58. }
  59. }
  60. if $host_name_template {
  61. ini_setting { 'host_name_template':
  62. section => 'graphite',
  63. setting => 'host_name_template',
  64. value => $host_name_template,
  65. }
  66. }
  67. if $install_method == 'git' {
  68. if $pkg_deps {
  69. package { $pkg_deps:
  70. ensure => $pkg_ensure,
  71. before => Vcsrepo['graphite'],
  72. }
  73. }
  74. vcsrepo { 'graphite':
  75. ensure => latest,
  76. path => "${web_root}/modules/graphite",
  77. provider => 'git',
  78. revision => $git_revision,
  79. source => $git_repo,
  80. }
  81. }
  82. }