fuel-library/deployment/puppet/apt/manifests/hold.pp
Bogdan Dobrelya 0e0c6853fb Sync apt module from puppetlabs
v1.8.0 47c6f338eda98ed849531d92b63c5e33103f76e4
source https://github.com/puppetlabs/puppetlabs-apt

Related blueprint merge-openstack-puppet-modules
Related-bug: #1443800

Change-Id: I5f86751ba9b16fdedd209677bb67e23cdb85b44f
Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
2015-04-14 11:49:06 +02:00

55 lines
1.3 KiB
Puppet

# == 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.
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',
}
}
}