Defined Type: apt::hold

Defined in:
manifests/hold.pp

Overview

Define apt::hold

This defined type allows you to hold a package based on the version you require. It’s implemented by dropping an apt preferences file pinning the package to the version you require.

Parameters

version

The version at which you wish to pin a package.

This can either be the full version, such as 4:2.11.8.1-5, or a partial version, such as 4:2.11.*

package

default: $title, the title/name of the resource.

Name of the package that apt is to hold.

priority

default: 1001

The default priority of 1001 causes this preference to always win. By setting the priority to a number greater than 1000 apt will always install this version even if it means downgrading the currently installed version.

Parameters:

  • version (Any)
  • ensure (Any) (defaults to: 'present')
  • package (Any) (defaults to: $title)
  • priority (Any) (defaults to: 1001)


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
# File 'manifests/hold.pp', line 26

define apt::hold(
  $version,
  $ensure   = 'present',
  $package  = $title,
  $priority = 1001,
){

  validate_string($title)
  validate_re($ensure, ['^present|absent',])
  validate_string($package)
  validate_string($version)

  if ! is_integer($priority) {
    fail('$priority must be an integer')
  }

  if $ensure == 'present' {
    ::apt::pin { "hold_${package}":
      packages => $package,
      version  => $version,
      priority => $priority,
    }
  } else {
    ::apt::pin { "hold_${package}":
      ensure => 'absent',
    }
  }

}