File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#
22define collectd::plugin (
3- $ensure = ' present' ,
4- $content = undef ,
5- $order = ' 10' ,
6- $plugin = $name
3+ $ensure = ' present' ,
4+ $content = undef ,
5+ $order = ' 10' ,
6+ $globals = false ,
7+ $interval = undef ,
8+ $plugin = $name
79) {
810
911 include collectd::params
1618 owner => root,
1719 group => $root_group ,
1820 mode => ' 0640' ,
19- content => " # Generated by Puppet \n LoadPlugin ${plugin} \n\n ${content} " ,
21+ content => template ( ' collectd/loadplugin.conf.erb ' ) ,
2022 notify => Service[' collectd' ],
2123 }
2224
Original file line number Diff line number Diff line change 99
1010 collectd::plugin { 'perl' :
1111 ensure => $ensure ,
12+ globals => true ,
1213 order => $order ,
1314 content => template (' collectd/plugin/perl.conf.erb' )
1415 }
Original file line number Diff line number Diff line change 2626 should contain_file ( 'swap.load' ) . with ( {
2727 :ensure => 'present' ,
2828 :path => '/etc/collectd.d/10-swap.conf' ,
29- :content => "# Generated by Puppet\n LoadPlugin swap\n \n <Plugin swap>\n ReportByDevice false\n </Plugin>\n " ,
29+ :content => "# Generated by Puppet\n <LoadPlugin swap> \n Globals false \n </LoadPlugin> \n \n < Plugin swap>\n ReportByDevice false\n </Plugin>\n \n " ,
3030 } )
3131 end
3232 end
4242 should contain_file ( 'swap.load' ) . with ( {
4343 :ensure => 'present' ,
4444 :path => '/etc/collectd.d/10-swap.conf' ,
45- :content => "# Generated by Puppet\n LoadPlugin swap\n \n <Plugin swap>\n ReportByDevice false\n ReportBytes true\n </Plugin>\n " ,
45+ :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 " ,
4646 } )
4747 end
4848 end
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe 'collectd::plugin' , :type => :define do
4+
5+ context 'loading a plugin on collectd <= 4.9.4' do
6+ let ( :title ) { 'test' }
7+ let :facts do
8+ {
9+ :collectd_version => '5.3' ,
10+ :osfamily => 'Debian' ,
11+ }
12+ end
13+
14+ it 'Will create /etc/collectd/conf.d/10-test.conf with the LoadPlugin syntax with brackets' do
15+ should contain_file ( 'test.load' ) . with_content ( /<LoadPlugin/ )
16+ end
17+ end
18+
19+
20+ context 'loading a plugin on collectd => 4.9.3' do
21+ let ( :title ) { 'test' }
22+ let :facts do
23+ {
24+ :collectd_version => '4.9.3' ,
25+ :osfamily => 'Debian' ,
26+ }
27+ end
28+
29+ it 'Will create /etc/collectd/conf.d/10-test.conf with the LoadPlugin syntax without brackets' do
30+ should contain_file ( 'test.load' ) . without_content ( /<LoadPlugin/ )
31+ end
32+ end
33+
34+ end
Original file line number Diff line number Diff line change 1+ # Generated by Puppet
2+ <% if @collectd_version and (scope.function_versioncmp([@collectd_version, '4.9.4']) >= 0) -%>
3+ <LoadPlugin <%= @plugin %> >
4+ Globals <%= @globals %>
5+ <% if @interval and @collectd_version and ( scope . function_versioncmp ( [ @collectd_version , '5.2' ] ) >= 0 ) -%>
6+ Interval <%= @interval %>
7+ <% end -%>
8+ </ LoadPlugin >
9+ <% else -%>
10+ LoadPlugin <%= @plugin %>
11+ <% end -%>
12+
13+ <%= @content %>
Original file line number Diff line number Diff line change 1- #
2- < LoadPlugin perl >
3- Globals true
4- </ LoadPlugin >
5-
61Include "<%= @conf_dir %> /perl/*.conf"
72
You can’t perform that action at this time.
0 commit comments