]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorMarkelov Anton <doublic@gmail.com>
Mon, 22 Oct 2012 06:06:04 +0000 (17:06 +1100)
committerMarkelov Anton <doublic@gmail.com>
Mon, 22 Oct 2012 06:06:04 +0000 (17:06 +1100)
README.md
manifests/pin.pp
spec/defines/pin_spec.rb

index 705cb33de5be1eac3c9995fa7c893a77c5f1004f..72a130c5e76cfc2b00a081184a7e90b82ab2e650 100644 (file)
--- a/README.md
+++ b/README.md
@@ -5,89 +5,102 @@ Provides helpful definitions for dealing with Apt.
 
 ## Usage
 
-### apt:builddep
+### apt
+The apt class provides a number of common resources and options which
+are shared by the various defined types in this module. This class
+should always be included in your manifests if you are using the `apt`
+module.
+
+    class { 'apt':
+      always_apt_update    => false,
+      disable_keys         => undef,
+      proxy_host           => false,
+      proxy_port           => '8080',
+      purge_sources_list   => false,
+      purge_sources_list_d => false,
+      purge_preferences_d  => false
+    }
+
+### apt::builddep
 Install the build depends of a specified package.
-<pre>
-apt::builddep { "glusterfs-server": }
-</pre>
+
+    apt::builddep { "glusterfs-server": }
 
 ### apt::force
-Force a package to be installed from a specific release.  Useful when using repositories like Debian unstable in Ubuntu.
-<pre>
-apt::force { "glusterfs-server":
-       release => "unstable",
-       version => '3.0.3',
-       require => Apt::Source["debian_unstable"],
-}
-</pre>
+Force a package to be installed from a specific release.  Useful when
+using repositories like Debian unstable in Ubuntu.
+
+    apt::force { "glusterfs-server":
+         release => "unstable",
+         version => '3.0.3',
+         require => Apt::Source["debian_unstable"],
+    }
 
 ### apt::pin
 Add an apt pin for a certain release.
-<pre>
-apt::pin { "karmic": priority => 700 }
-apt::pin { "karmic-updates": priority => 700 }
-apt::pin { "karmic-security": priority => 700 }
-</pre>
+
+    apt::pin { "karmic": priority => 700 }
+    apt::pin { "karmic-updates": priority => 700 }
+    apt::pin { "karmic-security": priority => 700 }
 
 ### apt::ppa
 Add a ppa repository using `add-apt-repository`.  Somewhat experimental.
-<pre>
-apt::ppa { "ppa:drizzle-developers/ppa": }
-</pre>
+
+    apt::ppa { "ppa:drizzle-developers/ppa": }
 
 ### apt::release
-Set the default apt release.  Useful when using repositories like Debian unstable in Ubuntu.
-<pre>
-apt::release { "karmic": }
-</pre>
+Set the default apt release.  Useful when using repositories like
+Debian unstable in Ubuntu.
+
+    apt::release { "karmic": }
 
 ### apt::source
 Add an apt source to `/etc/apt/sources.list.d/`.
-<pre>
-apt::source { "debian_unstable":
-  location          => "http://debian.mirror.iweb.ca/debian/",
-  release           => "unstable",
-  repos             => "main contrib non-free",
-  required_packages => "debian-keyring debian-archive-keyring",
-  key               => "55BE302B",
-  key_server        => "subkeys.pgp.net",
-  pin               => "-10",
-  include_src       => true
-}
-</pre>
-
-This source will configure your system for the Puppet Labs APT repository.
-<pre>
-apt::source { 'puppetlabs':
-  location   => 'http://apt.puppetlabs.com',
-  repos      => 'main',
-  key        => '4BD6EC30',
-  key_server => 'pgp.mit.edu',
-}
-</pre>
+
+    apt::source { "debian_unstable":
+      location          => "http://debian.mirror.iweb.ca/debian/",
+      release           => "unstable",
+      repos             => "main contrib non-free",
+      required_packages => "debian-keyring debian-archive-keyring",
+      key               => "55BE302B",
+      key_server        => "subkeys.pgp.net",
+      pin               => "-10",
+      include_src       => true
+    }
+
+This source will configure your system for the Puppet Labs APT
+repository.
+
+    apt::source { 'puppetlabs':
+      location   => 'http://apt.puppetlabs.com',
+      repos      => 'main',
+      key        => '4BD6EC30',
+      key_server => 'pgp.mit.edu',
+    }
 
 ### apt::key
 Add a key to the list of keys used by apt to authenticate packages.
-<pre>
-apt::key { "puppetlabs":
-  key        => "4BD6EC30",
-  key_server => "pgp.mit.edu",
-}
-</pre>
 
-<pre>
-apt::key { "jenkins":
-  key        => "D50582E6",
-  key_source => "http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key",
-}
-</pre>
+    apt::key { "puppetlabs":
+      key        => "4BD6EC30",
+      key_server => "pgp.mit.edu",
+    }
+
+    apt::key { "jenkins":
+      key        => "D50582E6",
+      key_source => "http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key",
+    }
 
-Note that use of the "key_source" parameter requires wget to be installed and working.
+Note that use of the "key_source" parameter requires wget to be
+installed and working.
 
 
 ## Contributors
-A lot of great people have contributed to this module. A somewhat current list follows.  
-Ben Godfrey <ben.godfrey@wonga.com>  
+A lot of great people have contributed to this module. A somewhat
+current list follows.
+
+Ben Godfrey <ben.godfrey@wonga.com>
+Branan Purvine-Riley <branan@puppetlabs.com>
 Christian G. Warden <cwarden@xerus.org>  
 Dan Bode <bodepd@gmail.com> <dan@puppetlabs.com>  
 Garrett Honeycutt <github@garretthoneycutt.com>  
index 3dadae6481ddf3c90c661e14b77964a765ba4a73..cebc6e7b0da2c390092324ad7c32c5e236dab641 100644 (file)
@@ -3,6 +3,7 @@
 
 define apt::pin(
   $ensure     = present,
+  $order      = '',
   $packages   = '*',
   $priority   = 0,
   $release    = '',
@@ -15,6 +16,10 @@ define apt::pin(
 
   $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 != '' {
     $pin = "release a=${release}"
   } elsif $origin != '' {
@@ -27,9 +32,13 @@ define apt::pin(
     $pin = "release a=${name}"
   }
 
+  $path = $order ? {
+    ''      => "${preferences_d}/${name}.pref",
+    default => "${preferences_d}/${order}-${name}.pref",
+  }
   file { "${name}.pref":
     ensure  => $ensure,
-    path    => "${preferences_d}/${name}.pref",
+    path    => $path,
     owner   => root,
     group   => root,
     mode    => '0644',
index bfa0126030abdddde3f8802af4ed34f531b97056..cd269d3b8bb11b3deff3831df99be63b5d877da8 100644 (file)
@@ -5,6 +5,7 @@ describe 'apt::pin', :type => :define do
   let :default_params do
     {
       :ensure   => 'present',
+      :order    => '',
       :packages => '*',
       :priority => '0',
       :release  => nil
@@ -16,6 +17,11 @@ describe 'apt::pin', :type => :define do
       :packages  => 'apache',
       :priority  => '1'
     },
+    {
+      :order     => 50,
+      :packages  => 'apache',
+      :priority  => '1'
+    },
     {
       :ensure    => 'absent',
       :packages  => 'apache',
@@ -40,7 +46,7 @@ describe 'apt::pin', :type => :define do
 
       it { should contain_file("#{title}.pref").with({
           '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',
           'group'   => 'root',
           'mode'    => '0644',