Puppet Class: collectd::plugin::rabbitmq

Defined in:
manifests/plugin/rabbitmq.pp

Overview

rabbitmq plugin 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 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"',

Parameters:

  • config (Hash) (defaults to: { 'Username' => 'guest', 'Password' => 'guest', 'Scheme' => 'http', 'Port' => '15672', 'Host' => $facts['networking']['fqdn'], 'Realm' => '"RabbitMQ Management"', })
  • ensure (String) (defaults to: 'present')
  • interval (Any) (defaults to: undef)
  • manage_package (Any) (defaults to: undef)
  • package_name (Any) (defaults to: 'collectd-rabbitmq')
  • package_provider (Any) (defaults to: 'pip')
  • provider_proxy (Any) (defaults to: undef)
  • custom_types_db (Any) (defaults to: undef)


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
# File 'manifests/plugin/rabbitmq.pp', line 43

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' and versioncmp($facts['os']['release']['major'], '11') >= 0 or
  $facts['os']['family'] == 'RedHat' and versioncmp($facts['os']['release']['major'], '8') >= 0 or
  $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '20.04') >= 0 {
    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],
  }
}