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

Examples:

Sample usage on CentOS 7

yum::versionlock { '0:bash-4.1.2-9.el7.*':
  ensure => present,
}

Sample usage on CentOS 8

yum::versionlock { 'bash':
  ensure => present,
  version => '4.1.2',
  release => '9.el8',
  epoch   => 0,
  arch    => 'noarch',
}

Sample usage on CentOS 7 with new style version, release, epoch, name parameters.

yum::versionlock { 'bash':
  ensure => present,
  version => '3.1.2',
  release => '9.el7',
  epoch   => 0,
  arch    => 'noarch',
}

Parameters:

  • ensure (Enum['present', 'absent', 'exclude']) (defaults to: 'present')

    Specifies if versionlock should be ‘present`, `absent` or `exclude`.

  • version (Optional[Yum::RpmVersion]) (defaults to: undef)

    Version of the package if CentOS 8 mechanism is used. This must be set for dnf based systems (e.g CentOS 8). If version is set then the name var is assumed to a package name and not the full versionlock string.

  • release (Yum::RpmRelease) (defaults to: '*')

    Release of the package if CentOS 8 mechanism is used.

  • arch (Variant[Yum::RpmArch, Enum['*']]) (defaults to: '*')

    Arch of the package if CentOS 8 mechanism is used.

  • epoch (Integer[0]) (defaults to: 0)

    Epoch of the package if CentOS 8 mechanism is used.

See Also:



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,
    }
  }
}