Puppet Class: collectd::plugin::python

Defined in:
manifests/plugin/python.pp

Overview

Parameters:

  • modulepaths (Any) (defaults to: [])
  • ensure (Any) (defaults to: present)
  • modules (Any) (defaults to: {})
  • globals (Any) (defaults to: true)
  • order (Any) (defaults to: '10')
  • interval (Any) (defaults to: undef)
  • encoding (Any) (defaults to: undef)
  • interactive (Any) (defaults to: false)
  • logtraces (Any) (defaults to: false)


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

class collectd::plugin::python (
  $modulepaths = [],
  $ensure      = present,
  $modules     = {},
  # Unlike most other plugins, this one should set "Globals true". This will cause collectd
  # to export the name of all objects in the Python interpreter for all plugins to see.
  $globals     = true,
  $order       = '10',
  $interval    = undef,
  # Python 2 defaults to 'ascii' and Python 3 to 'utf-8'
  $encoding    = undef,
  $interactive = false,
  $logtraces   = false,
) {
  include collectd::params

  validate_hash($modules)
  validate_bool($interactive)
  validate_bool($logtraces)
  validate_bool($globals)
  validate_array($modulepaths)

  $module_dirs = empty($modulepaths) ? {
    true  => [$collectd::params::python_dir],
    # use paths provided by the user
    false => $modulepaths
  }

  collectd::plugin {'python':
    ensure   => $ensure,
    interval => $interval,
    order    => $order,
    globals  => $globals,
  }

  $ensure_modulepath = $ensure ? {
    'absent' => $ensure,
    default  => 'directory',
  }

  ensure_resource('file', $module_dirs,
    {
      'ensure'  => $ensure_modulepath,
      'mode'    => '0750',
      'owner'   => 'root',
      'group'   => $collectd::params::root_group,
      'require' => Package[$collectd::params::package]
    }
  )

  # should be loaded after global plugin configuration
  $python_conf = "${collectd::params::plugin_conf_dir}/python-config.conf"

  concat{ $python_conf:
    ensure         => $ensure,
    mode           => '0640',
    owner          => 'root',
    group          => $collectd::params::root_group,
    notify         => Service['collectd'],
    ensure_newline => true,
  }

  concat::fragment{'collectd_plugin_python_conf_header':
    order   => '00',
    content => template('collectd/plugin/python/header.conf.erb'),
    target  => $python_conf,
  }

  concat::fragment{'collectd_plugin_python_conf_footer':
    order   => '99',
    content => '</Plugin>',
    target  => $python_conf,
  }

  $defaults = {
    'ensure'     => $ensure,
    'modulepath' => $module_dirs[0],
  }
  create_resources(collectd::plugin::python::module, $modules, $defaults)
}