Defined Type: yum::versionlock
- Defined in:
- manifests/versionlock.pp
Summary
Locks package from updates.Overview
Note:
The resource title must use the format By default on CentOS 7 the following format is used. “%EPOCH:%NAME-%VERSION-%RELEASE.%ARCH”. This can be retrieved via the command ‘rpm -q –qf ’%EPOCH:%NAME-%VERSION-%RELEASE.%ARCH‘. If “%EPOCH” returns as ’(none)‘, it should be set to ’0’. Wildcards may be used within token slots, but must not cover seperators, e.g., ‘0:b*sh-4.1.2-9.*’ covers Bash version 4.1.2, revision 9 on all architectures. By default on CentOS 8 and newer the resource title to just set the package name. If a version is set on CentOS 7 then it behaves like CentOS 8
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'manifests/versionlock.pp', line 56
define yum::versionlock (
Enum['present', 'absent', 'exclude'] $ensure = 'present',
Optional[Yum::RpmVersion] $version = undef,
Yum::RpmRelease $release = '*',
Integer[0] $epoch = 0,
Variant[Yum::RpmArch, Enum['*']] $arch = '*',
) {
require yum::plugin::versionlock
$line_prefix = $ensure ? {
'exclude' => '!',
default => '',
}
if $facts['package_provider'] == 'yum' and $version =~ Undef {
assert_type(Yum::VersionlockString, $name) |$_expected, $actual | {
# lint:ignore:140chars
fail("Package name must be formatted as %{EPOCH}:%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}, not \'${actual}\'. See Yum::Versionlock documentation for details.")
# lint:endignore
}
$_versionlock = "${line_prefix}${name}"
} else {
assert_type(Yum::RpmName, $name) |$_expected, $actual | {
fail("Package name must be formatted as Yum::RpmName, not \'${actual}\'. See Yum::Rpmname documentation for details.")
}
assert_type(Yum::RpmVersion, $version) |$_expected, $actual | {
fail("Version must be formatted as Yum::RpmVersion, not \'${actual}\'. See Yum::RpmVersion documentation for details.")
}
$_versionlock = $facts['package_provider'] ? {
'yum' => "${line_prefix}${epoch}:${name}-${version}-${release}.${arch}",
default => "${line_prefix}${name}-${epoch}:${version}-${release}.${arch}",
}
}
unless $ensure == 'absent' {
concat::fragment { "yum-versionlock-${name}":
content => "${_versionlock}\n",
target => $yum::plugin::versionlock::path,
}
}
}
|