Puppet Class: collectd::config
- Defined in:
- manifests/config.pp
Overview
Class: collectd::config
Setup collectd configuration structure. This will not load any plugin and won’t configure anything except a couple of paths. Use ‘collect::config::*` definitions to actually configure collectd.
Parameters:
[*confdir*]: - Directory where the collectd configuration is located.
[*rootdir*]: - A path matching the `--prefix` parameter collectd was
compiled with. If you install collectd with the official
RedHat/Debian packages you can leave this blank.
[*interval*]: - A hash of "plugin-name => custom-interval-value", if you
want to have per-plugin interval settings. Note: you'll
still need to use `collectd::plugin` or
`collectd::config::plugin` to load the plugin.
Sample Usage: see README and ‘collectd`. Also have a look at `/etc/collectd/collectd.conf` to get an idea of the configuration structure.
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'manifests/config.pp', line 22
class collectd::config (
$confdir = '/etc/collectd',
$rootdir = undef,
$interval = {},
) {
validate_absolute_path($confdir)
if $rootdir { validate_absolute_path($rootdir) }
validate_hash($interval)
validate_re($::osfamily, 'Debian|RedHat',
"Support for \$osfamily '${::osfamily}' not yet implemented.")
contain '::collectd::setup::defaultplugins'
$conffile = "${confdir}/collectd.conf"
$customtypesdb = "${confdir}/custom-types.db"
$globalsconf = "${confdir}/globals.conf"
$loadplugins = "${confdir}/loadplugins.conf"
$pluginsconfdir = "${confdir}/plugins"
$filtersconfdir = "${confdir}/filters"
if $rootdir {
$typesdb = "${rootdir}/types.db"
# TODO: make collectd work when installed from source
#file { '/etc/init.d/collectd':
# ensure => link,
# target => TODO,
#}
} else {
$typesdb = '/usr/share/collectd/types.db'
$changes = $::osfamily ? {
'Debian' => [
'set DISABLE 0',
'set USE_COLLECTDMON 1',
"set CONFIGFILE ${conffile}",
],
'RedHat' => [
"set CONFIG ${conffile}",
]
}
$inclfile = $::osfamily ? {
'Debian' => '/etc/default/collectd',
'RedHat' => '/etc/sysconfig/collectd',
}
augeas { 'setup collectd initscript':
incl => $inclfile,
lens => 'Shellvars.lns',
changes => $changes,
}
if ($::osfamily == 'RedHat') {
file { '/etc/collectd.conf':
ensure => link,
target => $conffile,
}
}
}
validate_absolute_path($customtypesdb)
Concat::Fragment <<| tag == 'collectd_typesdb' |>> {
target => $customtypesdb,
}
file { $confdir:
ensure => directory,
purge => true,
force => true,
recurse => true,
recurselimit => 1,
}
file { "${confdir}/collectd.conf.d":
ensure => directory,
}
file { "${confdir}/collectd.conf.d/000-README.conf":
ensure => file,
content => '# Placeholder file managed by puppet
#
# Add your custom collectd configuration files in this directory.
#
# Puppet will not remove/change any file in this directory.
',
}
file { $pluginsconfdir:
ensure => directory,
purge => true,
recurse => true,
force => true,
}
file { "${pluginsconfdir}/000-README.conf":
ensure => file,
content => '# Placeholder file managed by puppet
#
# Plugin configuration settings come in this directory.
#
# Use collectd::config::plugin to add files here, or manually add them in
# ../collectd.conf.d/ instead.
#
# Files added here manually will be removed.
',
}
file { $filtersconfdir:
ensure => directory,
purge => true,
recurse => true,
force => true,
}
file { "${filtersconfdir}/000-README.conf":
ensure => file,
content => '# Placeholder file managed by puppet
#
# Filter chains configuration come in this directory.
#
# Use collectd::config::chain to add files here, or manually add them in
# ../collectd.conf.d/ instead.
#
# Files added here manually will be removed.
',
}
file { $conffile:
ensure => file,
content => template('collectd/collectd.conf.erb'),
}
concat { [$globalsconf, $loadplugins, $customtypesdb ]: }
collectd::override { $name:
order => '01',
content => '[Service]
CapabilityBoundingSet=',
}
concat::fragment { 'globals_header':
target => $globalsconf,
order => '01',
content => '# file managed by puppet
# Global configuration settings come in here.
# Use collectd::config::global to define global settings.
',
}
concat::fragment { 'loadplugins_header':
target => $loadplugins,
order => '01',
content => '# file managed by puppet
# LoadPlugins statements all come in here.
# Use collectd::plugin or collectd::config::plugin to load plugins.
',
}
}
|