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

Install collectd-mcelog package on RedHat #962

Merged
merged 1 commit into from
Dec 17, 2020
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
19 changes: 19 additions & 0 deletions manifests/plugin/mcelog.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# https://collectd.org/documentation/manpages/collectd.conf.5.shtml#plugin_mcelog
class collectd::plugin::mcelog (
Enum['present', 'absent'] $ensure = 'present',
Optional[Boolean] $manage_package = undef,
Optional[Array] $package_install_options = $collectd::package_install_options,
# Log file option and memory option are mutualy exclusive.
Optional[String] $mceloglogfile = undef,
Optional[Collectd::MCELOG::Memory] $memory = {
Expand All @@ -10,6 +12,23 @@
) {
include collectd

$_manage_package = pick($manage_package, $collectd::manage_package)

if $ensure == 'present' {
$package_ensure = $collectd::package_ensure
} elsif $ensure == 'absent' {
$package_ensure = 'absent'
}

if $facts['os']['family'] == 'RedHat' {
if $_manage_package {
package { 'collectd-mcelog':
ensure => $package_ensure,
install_options => $package_install_options,
}
}
}

collectd::plugin { 'mcelog':
ensure => $ensure,
content => epp('collectd/plugin/mcelog.conf.epp', {
Expand Down
11 changes: 11 additions & 0 deletions spec/classes/collectd_plugin_mcelog_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
facts
end

let :pre_condition do
'include collectd'
end

it { is_expected.to compile.with_all_deps }

options = os_specific_options(facts)
Expand All @@ -22,6 +26,13 @@
it { is_expected.to contain_file('mcelog.load').with(content: %r{PersistentNotification false}) }
end

case facts[:os]['family']
when 'RedHat'
context 'on osfamily => RedHat' do
it { is_expected.to contain_package('collectd-mcelog').with(ensure: 'present') }
end
end

context ':ensure => :mceloglogfile => true' do
let :params do
{
Expand Down