Skip to content

Commit

Permalink
Uses the LoadPlugin syntax with bracket when supported
Browse files Browse the repository at this point in the history
This is fully backwards compatible.

The version check is done exactly how it's supposed to ; I checked the
sources of collectd to be sure there's no conflict.

Globals has always defaulted to false so I'm making it default to false
in this module. I'm not setting it undef because that's a boolean and we
got issues with checking if a boolean is false or undef (see redhat-openstack#182).
  • Loading branch information
txaj committed Dec 11, 2014
1 parent 1b75c78 commit b671d00
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
12 changes: 7 additions & 5 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#
define collectd::plugin (
$ensure = 'present',
$content = undef,
$order = '10',
$plugin = $name
$ensure = 'present',
$content = undef,
$order = '10',
$globals = false,
$interval = undef,
$plugin = $name
) {

include collectd::params
Expand All @@ -16,7 +18,7 @@
owner => root,
group => $root_group,
mode => '0640',
content => "# Generated by Puppet\nLoadPlugin ${plugin}\n\n${content}",
content => template('collectd/loadplugin.conf.erb'),
notify => Service['collectd'],
}

Expand Down
4 changes: 2 additions & 2 deletions spec/classes/collectd_plugin_swap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
should contain_file('swap.load').with({
:ensure => 'present',
:path => '/etc/collectd.d/10-swap.conf',
:content => "# Generated by Puppet\nLoadPlugin swap\n\n<Plugin swap>\n ReportByDevice false\n</Plugin>\n",
:content => "# Generated by Puppet\n<LoadPlugin swap>\n Globals false\n</LoadPlugin>\n\n<Plugin swap>\n ReportByDevice false\n</Plugin>\n\n",
})
end
end
Expand All @@ -42,7 +42,7 @@
should contain_file('swap.load').with({
:ensure => 'present',
:path => '/etc/collectd.d/10-swap.conf',
:content => "# Generated by Puppet\nLoadPlugin swap\n\n<Plugin swap>\n ReportByDevice false\n ReportBytes true\n</Plugin>\n",
:content => "# Generated by Puppet\n<LoadPlugin swap>\n Globals false\n</LoadPlugin>\n\n<Plugin swap>\n ReportByDevice false\n ReportBytes true\n</Plugin>\n\n",
})
end
end
Expand Down
13 changes: 13 additions & 0 deletions templates/loadplugin.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by Puppet
<% if @collectd_version and (scope.function_versioncmp([@collectd_version, '4.9.4']) >= 0) -%>
<LoadPlugin <%= @plugin %>>
Globals <%= @globals %>
<% if @interval and @collectd_version and (scope.function_versioncmp([@collectd_version, '5.2']) >= 0) -%>
Interval <%= @interval %>
<% end -%>
</LoadPlugin>
<% else -%>
LoadPlugin <%= @plugin %>
<% end -%>

<%= @content %>

0 comments on commit b671d00

Please sign in to comment.