2013-01-02 14:12:11 +01:00
|
|
|
define apt::preferences_snippet (
|
2013-01-23 23:10:40 +01:00
|
|
|
$priority = undef,
|
2012-06-18 22:57:13 +02:00
|
|
|
$package = false,
|
2010-10-17 14:13:02 +02:00
|
|
|
$ensure = 'present',
|
2010-10-25 06:14:33 +02:00
|
|
|
$source = '',
|
2012-06-08 18:30:23 +02:00
|
|
|
$release = '',
|
2013-01-02 14:12:11 +01:00
|
|
|
$pin = ''
|
|
|
|
) {
|
2010-12-07 19:18:41 +01:00
|
|
|
|
2012-06-18 22:57:13 +02:00
|
|
|
$real_package = $package ? {
|
|
|
|
false => $name,
|
|
|
|
default => $package,
|
|
|
|
}
|
|
|
|
|
2013-01-23 23:10:40 +01:00
|
|
|
if $ensure == 'present' {
|
2013-06-20 21:32:51 +02:00
|
|
|
if $apt::custom_preferences == false {
|
2013-01-23 23:10:40 +01:00
|
|
|
fail('Trying to define a preferences_snippet with $custom_preferences set to false.')
|
|
|
|
}
|
2010-10-25 18:17:50 +02:00
|
|
|
|
2013-01-23 23:10:40 +01:00
|
|
|
if $priority == undef {
|
|
|
|
fail('apt::preferences_snippet requires the \'priority\' argument to be set')
|
|
|
|
}
|
|
|
|
|
|
|
|
if !$pin and !$release {
|
|
|
|
fail('apt::preferences_snippet requires one of the \'pin\' or \'release\' argument to be set')
|
|
|
|
}
|
|
|
|
if $pin and $release {
|
|
|
|
fail('apt::preferences_snippet requires either a \'pin\' or \'release\' argument, not both')
|
|
|
|
}
|
2012-06-08 18:30:23 +02:00
|
|
|
}
|
|
|
|
|
2012-09-20 09:55:58 +02:00
|
|
|
file { "/etc/apt/preferences.d/${name}":
|
2010-10-17 13:58:59 +02:00
|
|
|
ensure => $ensure,
|
2016-01-05 11:39:57 +01:00
|
|
|
owner => root, group => 0, mode => '0644',
|
2016-01-26 14:42:17 +01:00
|
|
|
before => Exec['apt_updated'];
|
2010-10-17 13:58:59 +02:00
|
|
|
}
|
2010-10-25 06:14:33 +02:00
|
|
|
|
|
|
|
case $source {
|
2010-10-28 22:05:37 +02:00
|
|
|
'': {
|
2012-06-08 18:30:23 +02:00
|
|
|
case $release {
|
|
|
|
'': {
|
2012-09-20 09:55:58 +02:00
|
|
|
File["/etc/apt/preferences.d/${name}"]{
|
2013-01-02 14:12:11 +01:00
|
|
|
content => template('apt/preferences_snippet.erb')
|
2012-06-08 18:30:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default: {
|
2012-09-20 09:55:58 +02:00
|
|
|
File["/etc/apt/preferences.d/${name}"]{
|
2013-01-02 14:12:11 +01:00
|
|
|
content => template('apt/preferences_snippet_release.erb')
|
2012-06-08 18:30:23 +02:00
|
|
|
}
|
|
|
|
}
|
2010-10-28 22:05:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default: {
|
2012-09-20 09:55:58 +02:00
|
|
|
File["/etc/apt/preferences.d/${name}"]{
|
2010-10-25 06:14:33 +02:00
|
|
|
source => $source
|
|
|
|
}
|
2010-10-28 22:05:37 +02:00
|
|
|
}
|
2010-10-25 06:14:33 +02:00
|
|
|
}
|
2010-10-17 13:58:59 +02:00
|
|
|
}
|