]> gitweb.fluxo.info Git - puppet-apt.git/commitdiff
Don't check for a package priority to be set when removing an APT preferences snippet.
authorintrigeri <intrigeri@boum.org>
Wed, 23 Jan 2013 22:10:40 +0000 (23:10 +0100)
committerGabriel Filion <lelutin@gmail.com>
Sat, 16 Feb 2013 19:58:43 +0000 (14:58 -0500)
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.

manifests/preferences_snippet.pp

index 0bff85c17d23b5f31fa89fc7d8415ffb586c28cd..5ae748b0ea028c55a095a2a2c0720226f1616964 100644 (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}":