28
|
1 |
# Define: yum::versionlock |
|
2 |
# |
|
3 |
# This definition locks package from updates. |
|
4 |
# |
|
5 |
# Parameters: |
|
6 |
# [*ensure*] - specifies if versionlock should be present, absent or exclude |
|
7 |
# [*path*] - configuration of Yum plugin versionlock |
|
8 |
# |
|
9 |
# Actions: |
|
10 |
# |
|
11 |
# Requires: |
|
12 |
# RPM based system, Yum versionlock plugin |
|
13 |
# |
|
14 |
# Sample usage: |
|
15 |
# yum::versionlock { '0:bash-4.1.2-9.el6_2.*': |
|
16 |
# ensure => present, |
|
17 |
# } |
|
18 |
# |
|
19 |
define yum::versionlock ( |
|
20 |
$ensure = present, |
|
21 |
$path = '/etc/yum/pluginconf.d/versionlock.list' |
|
22 |
) { |
|
23 |
require yum::plugin::versionlock |
|
24 |
|
|
25 |
if ($name =~ /^[0-9]+:.+\*$/) { |
|
26 |
$_name = $name |
|
27 |
} elsif ($name =~ /^[0-9]+:.+-.+-.+\./) { |
|
28 |
$_name= "${name}*" |
|
29 |
} else { |
|
30 |
fail('Package name must be formated as \'EPOCH:NAME-VERSION-RELEASE.ARCH\'') |
|
31 |
} |
|
32 |
|
|
33 |
case $ensure { |
|
34 |
present,absent,exclude: { |
|
35 |
if ($ensure == present) or ($ensure == absent) { |
|
36 |
file_line { "versionlock.list-${name}": |
|
37 |
ensure => $ensure, |
|
38 |
line => $_name, |
|
39 |
path => $path, |
|
40 |
} |
|
41 |
} |
|
42 |
|
|
43 |
if ($ensure == exclude) or ($ensure == absent) { |
|
44 |
file_line { "versionlock.list-!${name}": |
|
45 |
ensure => $ensure, |
|
46 |
line => "!${_name}", |
|
47 |
path => $path, |
|
48 |
} |
|
49 |
} |
|
50 |
} |
|
51 |
|
|
52 |
default: { |
|
53 |
fail("Invalid ensure state: ${ensure}") |
|
54 |
} |
|
55 |
} |
|
56 |
} |