Skip to content

Commit

Permalink
Merge a788df8 into 09ed0b9
Browse files Browse the repository at this point in the history
  • Loading branch information
yuav committed Dec 12, 2016
2 parents 09ed0b9 + a788df8 commit 52656b3
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
$read_threads = 5
$write_threads = 5
$timeout = 2
$typesdb = []
$typesdb = [ '/usr/share/collectd/types.db' ]
$write_queue_limit_high = undef
$write_queue_limit_low = undef
$package_ensure = 'present'
Expand Down
6 changes: 6 additions & 0 deletions manifests/plugin/rabbitmq.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
$package_name = 'collectd-rabbitmq',
$package_provider = 'pip',
$provider_proxy = undef,
$custom_types_db = '/usr/local/share/collectd-rabbitmq/types.db.custom',
) {
include ::collectd

Expand Down Expand Up @@ -97,6 +98,11 @@
install_options => $install_options,
}

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

collectd::plugin::python::module { 'collectd_rabbitmq.collectd_plugin':
ensure => $ensure,
config => [$config],
Expand Down
5 changes: 5 additions & 0 deletions spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,10 @@ class { '::collectd::plugin::rabbitmq': }
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end

describe file('/etc/collectd/conf.d/10-rabbitmq.conf') do
it { is_expected.to be_file }
it { is_expected.to contain 'TypesDB "/usr/local/share/collectd-rabbitmq/types.db.custom"' }
end
end
end
1 change: 0 additions & 1 deletion spec/classes/collectd_init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
it { is_expected.to contain_file('collectd.conf').with_content(%r{Timeout}) }
it { is_expected.to contain_file('collectd.conf').with_content(%r{ReadThreads}) }
it { is_expected.to contain_file('collectd.conf').with_content(%r{WriteThreads}) }
it { is_expected.to contain_file('collectd.conf').without_content(%r{^TypesDB}) }
it { is_expected.to contain_file('collectd.conf').without_content(%r{^WriteQueueLimitLow}) }
it { is_expected.to contain_file('collectd.conf').without_content(%r{^WriteQueueLimitHigh}) }
it { is_expected.to contain_file('collectd.conf').without_content(%r{^CollectInternalStats}) }
Expand Down
22 changes: 22 additions & 0 deletions spec/classes/collectd_plugin_rabbitmq_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@
it 'Realm set to "RabbitMQ Management"' do
is_expected.to contain_concat_fragment('collectd_plugin_python_conf_collectd_rabbitmq.collectd_plugin').with_content(%r{Realm "RabbitMQ Management"})
end

it 'Load custom TypesDB in included config' do
is_expected.to contain_file('rabbitmq.load').with_content(%r{TypesDB "/usr/local/share/collectd-rabbitmq/types.db.custom"})
end
end

context 'override custom TypesDB with new value' do
let :facts do
{
osfamily: 'RedHat',
collectd_version: '5.5',
operatingsystemmajrelease: '7',
python_dir: '/usr/local/lib/python2.7/dist-packages'
}
end
let :params do
{ custom_types_db: '/var/custom/types.db' }
end

it 'override custom TypesDB' do
is_expected.to contain_file('rabbitmq.load').with_content(%r{TypesDB "/var/custom/types.db"})
end
end

context 'override Username to foo' do
Expand Down
2 changes: 0 additions & 2 deletions templates/collectd.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ FQDNLookup true
#PluginDir "/usr/lib/collectd"
<% if @typesdb and not @typesdb.empty? -%>
TypesDB<% @typesdb.each do |path| -%> "<%= path %>"<% end %>
<% else -%>
#TypesDB "/usr/share/collectd/types.db" "/etc/collectd/my_types.db"
<% end -%>
<% if @write_queue_limit_high -%>
WriteQueueLimitHigh <%= @write_queue_limit_high %>
Expand Down
5 changes: 5 additions & 0 deletions templates/plugin/rabbitmq.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generated by Puppet
# Rest of RabbitMQ plugin config is in python.conf
<% if @custom_types_db -%>
TypesDB "<%= @custom_types_db %>"
<% end -%>

0 comments on commit 52656b3

Please sign in to comment.