-
-
Notifications
You must be signed in to change notification settings - Fork 272
/
rabbitmq.pp
128 lines (118 loc) · 3.62 KB
/
rabbitmq.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# rabbitmq plugin
# https://pypi.python.org/pypi/collectd-rabbitmq
#
# == Class collectd::plugin::rabbitmq
#
# Configures rabbitmq metrics collection. Optionally installs the plugin
# Note, it is up to you to support package installation and sources
#
# === Parameters:
# [*ensure*]
# String
# Passed to package and collectd::plugin resources ( both )
# Default: present
#
# [*interval*]
# Integer
# Interval setting for the plugin
# Default: undef
#
# [*manage_package*]
# Boolean
# Toggles installation of plugin. Please reference https://collectd-rabbitmq.readthedocs.org/en/latest/installation.html
# Default: undef
#
# [*package_provider*]
# String
# Passed to package resource
# Default: pip
#
# [*config*]
# Hash
# Contains key/value passed to the python module to configure the plugin
# Note we have had issues with the Realm value and quoting, seems to be an issue with quoting. Multi-word values need to be wrapped in '"xxxx"'
# Default: {
# 'Username' => 'guest',
# 'Password' => 'guest_pass',
# 'Scheme' => 'http',
# 'Port' => '15672',
# 'Host' => $facts['fqdn'],
# 'Realm' => '"RabbitMQ Management"',
# }
#
class collectd::plugin::rabbitmq (
# lint:ignore:parameter_order
Hash $config = {
'Username' => 'guest',
'Password' => 'guest',
'Scheme' => 'http',
'Port' => '15672',
'Host' => $facts['networking']['fqdn'],
'Realm' => '"RabbitMQ Management"',
},
# lint:endignore
String $ensure = 'present',
$interval = undef,
$manage_package = undef,
$package_name = 'collectd-rabbitmq',
$package_provider = 'pip',
$provider_proxy = undef,
$custom_types_db = undef,
) {
include collectd
if $facts['os']['family'] == 'Debian' or
$facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'], '8') >= 0 or
$facts['os']['name'] == 'Ubuntu' {
fail('https://pypi.org/project/collectd-rabbitmq/ does not support Python 3')
}
case $facts['os']['family'] {
'RedHat': {
$_custom_types_db = '/usr/share/collectd-rabbitmq/types.db.custom'
}
default: {
$_custom_types_db = '/usr/local/share/collectd-rabbitmq/types.db.custom'
}
}
$_real_custom_types_db = pick($custom_types_db, $_custom_types_db)
$_manage_package = pick($manage_package, $collectd::manage_package)
if ($_manage_package) {
if (!defined(Package['python-pip'])) {
package { 'python-pip': ensure => 'present', }
Package[$package_name] {
require => Package['python-pip'],
}
if $facts['os']['family'] == 'RedHat' {
# Epel is installed in install.pp if manage_repo is true
# python-pip doesn't exist in base for RedHat. Need epel installed first
if (defined(Class['epel'])) {
Package['python-pip'] {
require => Class['epel'],
}
}
}
}
}
if ($_manage_package) and ($provider_proxy) {
$install_options = [{ '--proxy' => $provider_proxy }]
} else {
$install_options = undef
}
package { $package_name:
ensure => $ensure,
provider => $package_provider,
install_options => $install_options,
}
file { 'rabbitmq.load':
ensure => $ensure,
path => "${collectd::plugin_conf_dir}/10-rabbitmq.conf",
owner => $collectd::config_owner,
group => $collectd::config_group,
mode => $collectd::config_mode,
content => template('collectd/plugin/rabbitmq.conf.erb'),
notify => Service[$collectd::service_name],
}
collectd::plugin::python::module { 'collectd_rabbitmq.collectd_plugin':
ensure => $ensure,
config => [$config],
}
}