Don't check for a package priority to be set when removing an APT preferences snippet.

The problem I'm facing is that the sanity checks prevent one from
using a simple:

  apt::preferences_snippet { "bla": ensure => absent }

So, first set a default value for the `priority' parameter, so
that it's not required anymore. Second, add a sanity check to
error out when priority is not set, to get the safe old behaviour.

Then, wrap all sanity checks about arguments within
a "if $ensure == 'present'" block.
This commit is contained in:
intrigeri 2013-01-23 23:10:40 +01:00 committed by Gabriel Filion
parent 14670466be
commit d51e2af9d4

View file

@ -1,5 +1,5 @@
define apt::preferences_snippet (
$priority,
$priority = undef,
$package = false,
$ensure = 'present',
$source = '',
@ -12,15 +12,21 @@ define apt::preferences_snippet (
default => $package,
}
if $custom_preferences == false {
fail('Trying to define a preferences_snippet with $custom_preferences set to false.')
}
if $ensure == 'present' {
if $custom_preferences == false {
fail('Trying to define a preferences_snippet with $custom_preferences set to false.')
}
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')
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')
}
}
file { "/etc/apt/preferences.d/${name}":