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). This
patch also makes sure, that all irrelevant config files are flush after
installation of each plugin package.
  • Loading branch information
paramite committed Jul 23, 2018
1 parent a8b4615 commit a864d0d
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 6 deletions.
13 changes: 13 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,12 @@
$java_dir = '/usr/share/collectd/java'
$default_python_dir = '/usr/lib/python2.7/site-packages'
$manage_repo = true
$package_configs = {
ovs_events => 'ovs-events.conf',
ovs_stats => 'ovs-stats.conf',
processes => 'processes-config.conf',
virt => 'libvirt.conf',
}
}
'Suse': {
$package_name = 'collectd'
Expand All @@ -82,6 +90,7 @@
$java_dir = undef
$default_python_dir = '/usr/share/collectd/python'
$manage_repo = false
$package_configs = {}
}
'FreeBSD': {
$package_name = 'collectd5'
Expand All @@ -94,6 +103,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 +116,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 +129,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 +142,7 @@
$java_dir = undef
$default_python_dir = '/usr/share/collectd/python'
$manage_repo = false
$package_configs = {}
}

default: {
Expand Down
31 changes: 25 additions & 6 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
$conf_dir = $::collectd::plugin_conf_dir
$config_group = $::collectd::config_group

$plugin_package = "collectd-${plugin}"
$flush_require = defined(Package[$plugin_package]) ? {
true => Package[$plugin_package],
default => undef
}

file { "${plugin}.load":
ensure => $ensure,
path => "${conf_dir}/${order}-${plugin}.conf",
Expand All @@ -26,18 +32,31 @@
# Older versions of this module didn't use the "00-" prefix.
# Delete those potentially left over files just to be sure.
file { "older_${plugin}.load":
ensure => absent,
path => "${conf_dir}/${plugin}.conf",
notify => Service[$collectd::service_name],
ensure => absent,
path => "${conf_dir}/${plugin}.conf",
notify => Service[$collectd::service_name],
require => $flush_require,
}

# Older versions of this module use the "00-" prefix by default.
# Delete those potentially left over files just to be sure.
if $order != '00' {
file { "old_${plugin}.load":
ensure => absent,
path => "${conf_dir}/00-${plugin}.conf",
notify => Service[$collectd::service_name],
ensure => absent,
path => "${conf_dir}/00-${plugin}.conf",
notify => Service[$collectd::service_name],
require => $flush_require,
}
}

# Delete default config file created by platform packaging and not matching
# plugin name
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],
require => $flush_require,
}
}
}
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
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_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

0 comments on commit a864d0d

Please sign in to comment.