From 8e31698c6262d03285bba4e898fd53772a3b57cb Mon Sep 17 00:00:00 2001 From: Nikita Uvarov Date: Wed, 11 Nov 2020 11:55:28 +0100 Subject: [PATCH] Install collectd-mcelog package on RedHat --- manifests/plugin/mcelog.pp | 19 +++++++++++++++++++ spec/classes/collectd_plugin_mcelog_spec.rb | 11 +++++++++++ 2 files changed, 30 insertions(+) diff --git a/manifests/plugin/mcelog.pp b/manifests/plugin/mcelog.pp index eb9f64a22..088ff379a 100644 --- a/manifests/plugin/mcelog.pp +++ b/manifests/plugin/mcelog.pp @@ -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 = { @@ -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', { diff --git a/spec/classes/collectd_plugin_mcelog_spec.rb b/spec/classes/collectd_plugin_mcelog_spec.rb index 29c292189..20f06da77 100644 --- a/spec/classes/collectd_plugin_mcelog_spec.rb +++ b/spec/classes/collectd_plugin_mcelog_spec.rb @@ -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) @@ -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 {