15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'manifests/init.pp', line 15
class mcelog (
Enum['present','absent'] $ensure = 'present',
Hash $settings = {},
Optional[Enum['running','stopped']] $service_ensure = undef,
) inherits mcelog::params {
case $ensure {
'present': {
$package_ensure = 'present'
$file_ensure = 'file'
$_service_ensure = pick($service_ensure, 'running')
$service_enable = true
}
'absent': {
$package_ensure = 'absent'
$file_ensure = 'absent'
$_service_ensure = pick($service_ensure, 'stopped')
$service_enable = false
}
default: {
# Do nothing
}
}
package { 'mcelog':
ensure => $package_ensure,
name => $::mcelog::params::package_name,
before => File['mcelog.conf'],
}
file { 'mcelog.conf':
ensure => $file_ensure,
path => $::mcelog::params::config_file_path,
owner => 'root',
group => 'root',
mode => '0644',
notify => Service['mcelog'],
}
$mcelog_ini_defaults = {
'path' => $::mcelog::params::config_file_path,
'require' => Package['mcelog'],
'notify' => Service['mcelog'],
}
if $ensure == 'present' {
create_ini_settings($settings, $mcelog_ini_defaults)
}
service { 'mcelog':
ensure => $_service_ensure,
enable => $service_enable,
name => $::mcelog::params::service_name,
hasstatus => true,
hasrestart => true,
}
}
|