(#16070) Allow optional order parameter to apt::pin
As the apt pinnings are parsed in ascending alphabetical order with first match wins within a given scope it is useful to be able to specify a ordering parameter. Then the name parameter can be kept to something meaningful.
This commit is contained in:
parent
710b1c6a66
commit
40f8755217
2 changed files with 17 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
define apt::pin(
|
define apt::pin(
|
||||||
$ensure = present,
|
$ensure = present,
|
||||||
|
$order = '',
|
||||||
$packages = '*',
|
$packages = '*',
|
||||||
$priority = 0,
|
$priority = 0,
|
||||||
$release = '',
|
$release = '',
|
||||||
|
@ -14,6 +15,10 @@ define apt::pin(
|
||||||
|
|
||||||
$preferences_d = $apt::params::preferences_d
|
$preferences_d = $apt::params::preferences_d
|
||||||
|
|
||||||
|
if $order != '' and !is_integer($order) {
|
||||||
|
fail('Only integers are allowed in the apt::pin order param')
|
||||||
|
}
|
||||||
|
|
||||||
if $release != '' {
|
if $release != '' {
|
||||||
$pin = "release a=${release}"
|
$pin = "release a=${release}"
|
||||||
} elsif $origin != '' {
|
} elsif $origin != '' {
|
||||||
|
@ -24,9 +29,13 @@ define apt::pin(
|
||||||
$pin = "release a=${name}"
|
$pin = "release a=${name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$path = $order ? {
|
||||||
|
'' => "${preferences_d}/${name}.pref",
|
||||||
|
default => "${preferences_d}/${order}-${name}.pref",
|
||||||
|
}
|
||||||
file { "${name}.pref":
|
file { "${name}.pref":
|
||||||
ensure => $ensure,
|
ensure => $ensure,
|
||||||
path => "${preferences_d}/${name}.pref",
|
path => $path,
|
||||||
owner => root,
|
owner => root,
|
||||||
group => root,
|
group => root,
|
||||||
mode => '0644',
|
mode => '0644',
|
||||||
|
|
|
@ -5,6 +5,7 @@ describe 'apt::pin', :type => :define do
|
||||||
let :default_params do
|
let :default_params do
|
||||||
{
|
{
|
||||||
:ensure => 'present',
|
:ensure => 'present',
|
||||||
|
:order => '',
|
||||||
:packages => '*',
|
:packages => '*',
|
||||||
:priority => '0',
|
:priority => '0',
|
||||||
:release => nil
|
:release => nil
|
||||||
|
@ -16,6 +17,11 @@ describe 'apt::pin', :type => :define do
|
||||||
:packages => 'apache',
|
:packages => 'apache',
|
||||||
:priority => '1'
|
:priority => '1'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
:order => 50,
|
||||||
|
:packages => 'apache',
|
||||||
|
:priority => '1'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
:ensure => 'absent',
|
:ensure => 'absent',
|
||||||
:packages => 'apache',
|
:packages => 'apache',
|
||||||
|
@ -40,7 +46,7 @@ describe 'apt::pin', :type => :define do
|
||||||
|
|
||||||
it { should contain_file("#{title}.pref").with({
|
it { should contain_file("#{title}.pref").with({
|
||||||
'ensure' => param_hash[:ensure],
|
'ensure' => param_hash[:ensure],
|
||||||
'path' => "/etc/apt/preferences.d/#{title}.pref",
|
'path' => "/etc/apt/preferences.d/#{param_hash[:order] == '' ? "" : "#{param_hash[:order]}-"}#{title}.pref",
|
||||||
'owner' => 'root',
|
'owner' => 'root',
|
||||||
'group' => 'root',
|
'group' => 'root',
|
||||||
'mode' => '0644',
|
'mode' => '0644',
|
||||||
|
|
Loading…
Reference in a new issue