Puppet Class: collectd::plugin::mongodb

Defined in:
manifests/plugin/mongodb.pp

Overview

Class: collectd::plugin::mongodb

Parameters:

  • ensure (Any) (defaults to: 'present')
  • interval (Any) (defaults to: undef)
  • db_host (Any) (defaults to: '127.0.0.1')
  • db_user (Any) (defaults to: undef)
  • db_pass (Any) (defaults to: undef)
  • db_port (Any) (defaults to: undef)
  • configured_dbs (Any) (defaults to: undef)
  • collectd_dir (Any) (defaults to: '/usr/lib/collectd')


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

class collectd::plugin::mongodb (
  $ensure         = 'present',
  $interval       = undef,
  $db_host        = '127.0.0.1',
  $db_user        = undef,
  $db_pass        = undef,
  $db_port        = undef,
  $configured_dbs = undef,
  $collectd_dir   = '/usr/lib/collectd',
) {

  include ::collectd

  validate_re($ensure,'^(present)|(absent)$',
    "collectd::plugin::mongodb::ensure is <${ensure}> and must be either 'present' or 'absent'.")

  if $interval != undef {
    validate_numeric($interval)
  }

  if $configured_dbs != undef {
    validate_array($configured_dbs)
    if ( $db_port == undef ) {

  fail('db_port is undefined, but must be set if configured_dbs is set.') }
    validate_string($db_port)
  }

  if ( $db_host != undef ) and ( is_ip_address($db_host) == false ) {

    fail("collectd::plugin::mongodb::db_host is <${db_host}> and must be a valid IP address.")
  }

  if $db_user == undef {
    fail('collectd::plugin::mongodb::db_user is <undef> and must be a mongodb username')
  }
  elsif $db_pass == undef {
    fail("collectd::plugin::mongodb::db_pass is <undef>, please specify the password for db user: ${db_user}")
  }

  collectd::plugin { 'mongodb':
    ensure   => $ensure,
    content  => template('collectd/plugin/mongodb.conf.erb'),
    interval => $interval,
  }
}