diff options
author | intrigeri <intrigeri@boum.org> | 2013-01-23 23:10:40 +0100 |
---|---|---|
committer | Gabriel Filion <lelutin@gmail.com> | 2013-02-16 14:58:43 -0500 |
commit | d51e2af9d452731f63b2fe16391e9cd2ff9d640f (patch) | |
tree | fc42404332cc78a21c15b062bfed7d8d6b1c39d7 /manifests/preferences_snippet.pp | |
parent | 14670466be5eceba043e697d5f6f0f0ada9d5b07 (diff) |
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.
Diffstat (limited to 'manifests/preferences_snippet.pp')
-rw-r--r-- | manifests/preferences_snippet.pp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp index 0bff85c..5ae748b 100644 --- a/manifests/preferences_snippet.pp +++ b/manifests/preferences_snippet.pp @@ -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}": |