From: Branan Purvine-Riley Date: Thu, 18 Oct 2012 23:45:15 +0000 (-0700) Subject: Merge pull request #83 from dalen/pin_order X-Git-Tag: 1.0.0~4 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=bd6830278391253d17e8f1991ea0ab6df8080502;hp=40f875521715759eddab7315f6d51e6519f016d8;p=puppet-modules%2Fpuppetlabs-apt.git Merge pull request #83 from dalen/pin_order (#16070) Allow optional order parameter to apt::pin --- diff --git a/README.md b/README.md index e8e5a9a..705cb33 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,17 @@ apt::source { "debian_unstable": 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.
diff --git a/manifests/backports.pp b/manifests/backports.pp
index aafdf96..e9180c4 100644
--- a/manifests/backports.pp
+++ b/manifests/backports.pp
@@ -16,7 +16,8 @@
 #
 # == Authors
 #
-# Ben Hughes, I think. At least blame him if this goes wrong. I just added puppet doc.
+# Ben Hughes, I think. At least blame him if this goes wrong.
+# I just added puppet doc.
 #
 # == Copyright
 #
@@ -27,18 +28,20 @@ class apt::backports(
 ) inherits apt::params {
 
   $release_real = downcase($release)
+  $key = $::lsbdistid ? {
+    'debian' => '55BE302B',
+    'ubuntu' => '437D05B5',
+  }
+  $repos = $::lsbdistid ? {
+    'debian' => 'main contrib non-free',
+    'ubuntu' => 'main universe multiverse restricted',
+  }
 
   apt::source { 'backports':
     location   => $location,
     release    => "${release_real}-backports",
-    repos      => $::lsbdistid ? {
-      'debian' => 'main contrib non-free',
-      'ubuntu' => 'main universe multiverse restricted',
-    },
-    key        => $::lsbdistid ? {
-      'debian' => '55BE302B',
-      'ubuntu' => '437D05B5',
-    },
+    repos      => $repos,
+    key        => $key,
     key_server => 'pgp.mit.edu',
     pin        => '200',
   }
diff --git a/manifests/conf.pp b/manifests/conf.pp
index 03aab8e..3c4cb19 100644
--- a/manifests/conf.pp
+++ b/manifests/conf.pp
@@ -1,7 +1,7 @@
 define apt::conf (
+  $content,
   $ensure   = present,
-  $priority = '50',
-  $content
+  $priority = '50'
 ) {
 
   include apt::params
diff --git a/manifests/force.pp b/manifests/force.pp
index d3d5962..75634b4 100644
--- a/manifests/force.pp
+++ b/manifests/force.pp
@@ -3,7 +3,8 @@
 
 define apt::force(
   $release = 'testing',
-  $version = false
+  $version = false,
+  $timeout = 300
 ) {
 
   $version_string = $version ? {
@@ -18,5 +19,6 @@ define apt::force(
   exec { "/usr/bin/aptitude -y -t ${release} install ${name}${version_string}":
     unless    => $install_check,
     logoutput => 'on_failure',
+    timeout   => $timeout,
   }
 }
diff --git a/manifests/init.pp b/manifests/init.pp
index 3587d21..442e04c 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -108,7 +108,7 @@ class apt(
   }
 
   # Need anchor to provide containment for dependencies.
-  anchor { "apt::update":
+  anchor { 'apt::update':
     require => Class['apt::update'],
   }
 }
diff --git a/manifests/key.pp b/manifests/key.pp
index dbbed2b..98a0f3a 100644
--- a/manifests/key.pp
+++ b/manifests/key.pp
@@ -54,7 +54,7 @@ define apt::key (
         }
       }
 
-      Anchor["apt::key $upkey present"] -> Anchor["apt::key/$title"]
+      Anchor["apt::key ${upkey} present"] -> Anchor["apt::key/${title}"]
 
     }
     absent: {
diff --git a/manifests/pin.pp b/manifests/pin.pp
index 96a3d70..cebc6e7 100644
--- a/manifests/pin.pp
+++ b/manifests/pin.pp
@@ -8,7 +8,8 @@ define apt::pin(
   $priority   = 0,
   $release    = '',
   $origin     = '',
-  $originator = ''
+  $originator = '',
+  $version    = ''
 ) {
 
   include apt::params
@@ -25,6 +26,8 @@ define apt::pin(
     $pin = "origin \"${origin}\""
   } elsif $originator != '' {
     $pin = "release o=${originator}"
+  } elsif $version != '' {
+    $pin = "version ${version}"
   } else {
     $pin = "release a=${name}"
   }
@@ -39,6 +42,6 @@ define apt::pin(
     owner   => root,
     group   => root,
     mode    => '0644',
-    content => template("apt/pin.pref.erb"),
+    content => template('apt/pin.pref.erb'),
   }
 }
diff --git a/manifests/ppa.pp b/manifests/ppa.pp
index 9527e0d..0458589 100644
--- a/manifests/ppa.pp
+++ b/manifests/ppa.pp
@@ -25,8 +25,10 @@ define apt::ppa(
     command   => "/usr/bin/add-apt-repository ${name}",
     creates   => "${sources_list_d}/${sources_list_d_filename}",
     logoutput => 'on_failure',
-    require   => [ File[$sources_list_d],
-                   Package['python-software-properties'] ],
+    require   => [
+      File[$sources_list_d],
+      Package['python-software-properties'],
+    ],
     notify    => Exec['apt_update'],
   }
 
diff --git a/manifests/source.pp b/manifests/source.pp
index 2c26227..a859174 100644
--- a/manifests/source.pp
+++ b/manifests/source.pp
@@ -4,7 +4,7 @@
 define apt::source(
   $ensure            = present,
   $location          = '',
-  $release           = $::lsbdistcodename,
+  $release           = 'UNDEF',
   $repos             = 'main',
   $include_src       = true,
   $required_packages = false,
@@ -21,8 +21,14 @@ define apt::source(
   $sources_list_d = $apt::params::sources_list_d
   $provider       = $apt::params::provider
 
-  if $release == undef {
-    fail('lsbdistcodename fact not available: release parameter required')
+  if $release == 'UNDEF' {
+    if $::lsbdistcodename == undef {
+      fail('lsbdistcodename fact not available: release parameter required')
+    } else {
+      $release_real = $::lsbdistcodename
+    }
+  } else {
+    $release_real = $release
   }
 
   file { "${name}.list":
diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb
index 583c619..0f37f63 100644
--- a/spec/defines/source_spec.rb
+++ b/spec/defines/source_spec.rb
@@ -42,6 +42,12 @@ describe 'apt::source', :type => :define do
       :location           => 'http://example.com',
       :release            => 'precise',
       :repos              => 'security',
+    },
+    {
+      :release            => '',
+    },
+    {
+      :release            => 'custom',
     }
   ].each do |param_set|
     describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
diff --git a/templates/source.list.erb b/templates/source.list.erb
index 3452691..faa7e28 100644
--- a/templates/source.list.erb
+++ b/templates/source.list.erb
@@ -1,5 +1,5 @@
 # <%= name %>
-deb <%= location %> <%= release %> <%= repos %>
+deb <%= location %> <%= release_real %> <%= repos %>
 <%- if include_src then -%>
-deb-src <%= location %> <%= release %> <%= repos %>
+deb-src <%= location %> <%= release_real %> <%= repos %>
 <%- end -%>
diff --git a/tests/key.pp b/tests/key.pp
index 5c62a4c..92679cf 100644
--- a/tests/key.pp
+++ b/tests/key.pp
@@ -1,5 +1,5 @@
 # Declare Apt key for apt.puppetlabs.com source
-apt::key { "puppetlabs":
-  key        => "4BD6EC30",
-  key_server => "pgp.mit.edu",
+apt::key { 'puppetlabs':
+  key        => '4BD6EC30',
+  key_server => 'pgp.mit.edu',
 }