28
|
1 |
# Class: yum |
|
2 |
# |
|
3 |
# Manage Yum configuration. |
|
4 |
# |
|
5 |
# Parameters: |
|
6 |
# [*keepcache*] - Yum option keepcache |
|
7 |
# [*debuglevel*] - Yum option debuglevel |
|
8 |
# [*exactarch*] - Yum option exactarch |
|
9 |
# [*obsoletes*] - Yum option obsoletes |
|
10 |
# [*gpgcheck*] - Yum option gpgcheck |
|
11 |
# [*installonly_limit*] - Yum option installonly_limit |
|
12 |
# [*keep_kernel_devel*] - On old kernels purge keep devel packages. |
|
13 |
# |
|
14 |
# Actions: |
|
15 |
# |
|
16 |
# Requires: |
|
17 |
# RPM based system |
|
18 |
# |
|
19 |
# Sample usage: |
|
20 |
# class { 'yum': |
|
21 |
# installonly_limit => 2, |
|
22 |
# } |
|
23 |
# |
|
24 |
class yum ( |
|
25 |
$keepcache = $yum::params::keepcache, |
|
26 |
$debuglevel = $yum::params::debuglevel, |
|
27 |
$exactarch = $yum::params::exactarch, |
|
28 |
$obsoletes = $yum::params::obsoletes, |
|
29 |
$gpgcheck = $yum::params::gpgcheck, |
|
30 |
$installonly_limit = $yum::params::installonly_limit, |
|
31 |
$keep_kernel_devel = $yum::params::keep_kernel_devel |
|
32 |
) inherits yum::params { |
|
33 |
|
|
34 |
validate_bool($keepcache, $exactarch, $obsoletes, $gpgcheck) |
|
35 |
validate_bool($keep_kernel_devel) |
|
36 |
|
|
37 |
unless is_integer($installonly_limit) { |
|
38 |
validate_string($installonly_limit) |
|
39 |
} |
|
40 |
|
|
41 |
unless is_integer($debuglevel) { |
|
42 |
validate_string($debuglevel) |
|
43 |
} |
|
44 |
|
|
45 |
# configure Yum |
|
46 |
yum::config { 'keepcache': |
|
47 |
ensure => bool2num($keepcache), |
|
48 |
} |
|
49 |
|
|
50 |
yum::config { 'debuglevel': |
|
51 |
ensure => $debuglevel, |
|
52 |
} |
|
53 |
|
|
54 |
yum::config { 'exactarch': |
|
55 |
ensure => bool2num($exactarch) |
|
56 |
} |
|
57 |
|
|
58 |
yum::config { 'obsoletes': |
|
59 |
ensure => bool2num($obsoletes) |
|
60 |
} |
|
61 |
|
|
62 |
yum::config { 'gpgcheck': |
|
63 |
ensure => bool2num($gpgcheck) |
|
64 |
} |
|
65 |
|
|
66 |
yum::config { 'installonly_limit': |
|
67 |
ensure => $installonly_limit, |
|
68 |
notify => Exec['package-cleanup_oldkernels'], |
|
69 |
} |
|
70 |
|
|
71 |
# cleanup old kernels |
|
72 |
ensure_packages(['yum-utils']) |
|
73 |
|
|
74 |
$_pc_cmd = delete_undef_values([ |
|
75 |
'/usr/bin/package-cleanup', |
|
76 |
'--oldkernels', |
|
77 |
"--count=${installonly_limit}", |
|
78 |
'-y', |
|
79 |
$keep_kernel_devel ? { |
|
80 |
true => '--keepdevel', |
|
81 |
default => undef, |
|
82 |
}, |
|
83 |
]) |
|
84 |
|
|
85 |
exec { 'package-cleanup_oldkernels': |
|
86 |
command => shellquote($_pc_cmd), |
|
87 |
refreshonly => true, |
|
88 |
require => Package['yum-utils'], |
|
89 |
} |
|
90 |
} |