Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush plugin config files #832

Merged
merged 1 commit into from
Jul 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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