Skip to content

Commit

Permalink
Flush plugin config files
Browse files Browse the repository at this point in the history
Even though the conf.d directory is flushed before creating configuration,
there are still some duplicate configuration files created by plugin package
installation performed after the general flush. This patch makes sure those
files are also removed (currently only for RedHat osfamily packaging).
  • Loading branch information
paramite committed Jul 20, 2018
1 parent a8795ff commit cd06de5
Show file tree
Hide file tree
Showing 16 changed files with 158 additions and 0 deletions.
25 changes: 25 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
$java_dir = '/usr/share/collectd/java'
$default_python_dir = '/usr/local/lib/python2.7/dist-packages'
$manage_repo = true
$package_configs = {}
}
'Solaris': {
$package_name = 'CSWcollectd'
Expand All @@ -58,6 +59,7 @@
$java_dir = undef
$default_python_dir = '/opt/csw/share/collectd/python'
$manage_repo = false
$package_configs = {}
}
'RedHat': {
$package_name = 'collectd'
Expand All @@ -70,6 +72,24 @@
$java_dir = '/usr/share/collectd/java'
$default_python_dir = '/usr/lib/python2.7/site-packages'
$manage_repo = true
$package_configs = {
apache => 'apache.conf',
dns => 'dns.conf',
hugepages => 'hugepages.conf',
ipmi => 'ipmi.conf',
mysql => 'mysql.conf',
nginx => 'nginx.conf',
ovs_events => 'ovs-events.conf',
ovs_stats => 'ovs-stats.conf',
ping => 'ping.conf',
postgresql => 'postgresql.conf',
processes => 'processes-config.conf',
rrdtool => 'rrdtool.conf',
sensors => 'sensors.conf',
snmp => 'snmp.conf',
write_prometheus => 'write_prometheus.conf',
virt => 'libvirt.conf',
}
}
'Suse': {
$package_name = 'collectd'
Expand All @@ -82,6 +102,7 @@
$java_dir = undef
$default_python_dir = '/usr/share/collectd/python'
$manage_repo = false
$package_configs = {}
}
'FreeBSD': {
$package_name = 'collectd5'
Expand All @@ -94,6 +115,7 @@
$java_dir = undef
$default_python_dir = '/usr/local/share/collectd/python'
$manage_repo = false
$package_configs = {}
}
'OpenBSD': {
$package_name = 'collectd'
Expand All @@ -106,6 +128,7 @@
$java_dir = undef
$default_python_dir = '/usr/local/share/collectd/python'
$manage_repo = false
$package_configs = {}
}
'Archlinux': {
$package_name = 'collectd'
Expand All @@ -118,6 +141,7 @@
$java_dir = undef
$default_python_dir = '/usr/share/collectd/python'
$manage_repo = false
$package_configs = {}
}
'Gentoo': {
$package_name = 'app-admin/collectd'
Expand All @@ -130,6 +154,7 @@
$java_dir = undef
$default_python_dir = '/usr/share/collectd/python'
$manage_repo = false
$package_configs = {}
}

default: {
Expand Down
9 changes: 9 additions & 0 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,13 @@
notify => Service[$collectd::service_name],
}
}

# Delete default config file created by platform packaging
if has_key($::collectd::package_configs, $plugin) {
file { "package_${plugin}.load":
ensure => absent,
path => "${conf_dir}/${::collectd::package_configs[$plugin]}",
notify => Service[$collectd::service_name],
}
}
}
6 changes: 6 additions & 0 deletions spec/classes/collectd_plugin_apache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@
is_expected.to contain_file('apache.load')
end
end

context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_apache.load').with_ensure('absent')
end
end
end
end
end
Expand Down
9 changes: 9 additions & 0 deletions spec/classes/collectd_plugin_dns_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@
end
end
end

case facts[:os]['family']
when 'RedHat'
context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_dns.load').with_ensure('absent')
end
end
end
end
end
end
9 changes: 9 additions & 0 deletions spec/classes/collectd_plugin_hugepages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@
)
end
end

case facts[:os]['family']
when 'RedHat'
context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_hugepages.load').with_ensure('absent')
end
end
end
end
end
end
9 changes: 9 additions & 0 deletions spec/classes/collectd_plugin_ipmi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@
)
end
end

case facts[:os]['family']
when 'RedHat'
context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_ipmi.load').with_ensure('absent')
end
end
end
end
end
end
9 changes: 9 additions & 0 deletions spec/classes/collectd_plugin_ovs_events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@
)
end
end

case facts[:os]['family']
when 'RedHat'
context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_ovs_events.load').with_ensure('absent')
end
end
end
end
end
end
9 changes: 9 additions & 0 deletions spec/classes/collectd_plugin_ovs_stats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@
)
end
end

case facts[:os]['family']
when 'RedHat'
context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_ovs_stats.load').with_ensure('absent')
end
end
end
end
end
end
13 changes: 13 additions & 0 deletions spec/classes/collectd_plugin_ping_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,19 @@
is_expected.to compile.and_raise_error(%r{String})
end
end

case facts[:os]['family']
when 'RedHat'
context 'on osfamily => RedHat' do
let :params do
{ hosts: ['google.com'] }
end

it 'Will delete packaging config file' do
is_expected.to contain_file('package_ping.load').with_ensure('absent')
end
end
end
end
end
end
9 changes: 9 additions & 0 deletions spec/classes/collectd_plugin_postgresql_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@
)
end
end

case facts[:os]['family']
when 'RedHat'
context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_postgresql.load').with_ensure('absent')
end
end
end
end
end
end
9 changes: 9 additions & 0 deletions spec/classes/collectd_plugin_processes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@
)
end
end

case facts[:os]['family']
when 'RedHat'
context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_processes.load').with_ensure('absent')
end
end
end
end
end
end
Expand Down
9 changes: 9 additions & 0 deletions spec/classes/collectd_plugin_rrdtool_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@
)
end
end

case facts[:os]['family']
when 'RedHat'
context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_rrdtool.load').with_ensure('absent')
end
end
end
end
end
end
6 changes: 6 additions & 0 deletions spec/classes/collectd_plugin_sensors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
end
end

context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_sensors.load').with_ensure('absent')
end
end

######################################################################
# Remaining parameter validation, compilation fails

Expand Down
9 changes: 9 additions & 0 deletions spec/classes/collectd_plugin_snmp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@
content: %r{Data "hc_octets".+Instance "IF-MIB::ifName".+Host "router".+Username "collectd".+SecurityLevel "authPriv".+AuthProtocol "SHA".+PrivacyProtocol "AES"}m)
end
end

case facts[:os]['family']
when 'RedHat'
context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_snmp.load').with_ensure('absent')
end
end
end
end
end
end
9 changes: 9 additions & 0 deletions spec/classes/collectd_plugin_virt_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@
with_content(%r{.*InterfaceFormat \"address\".*})
end
end

case facts[:os]['family']
when 'RedHat'
context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_virt.load').with_ensure('absent')
end
end
end
end
end
end
Expand Down
9 changes: 9 additions & 0 deletions spec/classes/collectd_plugin_write_prometheus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
)
end
end

case facts[:os]['family']
when 'RedHat'
context 'on osfamily => RedHat' do
it 'Will delete packaging config file' do
is_expected.to contain_file('package_write_prometheus.load').with_ensure('absent')
end
end
end
end
end
end

0 comments on commit cd06de5

Please sign in to comment.