Merge branch '1.6.x' of github.com:puppetlabs/puppetlabs-apt into 1.6.x
authorMorgan Haskel <morgan@puppetlabs.com>
Thu, 7 Aug 2014 18:52:17 +0000 (14:52 -0400)
committerMorgan Haskel <morgan@puppetlabs.com>
Thu, 7 Aug 2014 18:52:17 +0000 (14:52 -0400)
12 files changed:
README.md
manifests/hold.pp
manifests/init.pp
manifests/params.pp
manifests/ppa.pp
manifests/source.pp
spec/acceptance/apt_spec.rb
spec/acceptance/unattended_upgrade_spec.rb
spec/classes/params_spec.rb
spec/defines/hold_spec.rb
spec/defines/source_spec.rb
templates/source.list.erb

index 0749cb85af247cb6b784fb3a512fee343c9cfbd8..9f3bbbe7b762d13417c70eab8f0af4c78830974e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -202,7 +202,8 @@ Adds an apt source to `/etc/apt/sources.list.d/`.
       key               => '46925553',
       key_server        => 'subkeys.pgp.net',
       pin               => '-10',
-      include_src       => true
+      include_src       => true,
+      include_deb       => true
     }
 
 If you would like to configure your system so the source is the Puppet Labs APT repository
@@ -234,6 +235,7 @@ apt::sources:
       key_server: 'subkeys.pgp.net'
       pin: '-10'
       include_src: 'true'
+      include_deb: 'true'
 
   'puppetlabs':
       location: 'http://apt.puppetlabs.com'
index c4016c6e34ba609439dbe0d403edbd9abfec2c7a..61e8afcb3b572f4a6998bc9d1b4e9f4d66d50828 100644 (file)
@@ -40,13 +40,13 @@ define apt::hold(
   }
 
   if $ensure == 'present' {
-    ::apt::pin { "hold ${package} at ${version}":
+    ::apt::pin { "hold_${package}":
       packages => $package,
       version  => $version,
       priority => $priority,
     }
   } else {
-    ::apt::pin { "hold ${package} at ${version}":
+    ::apt::pin { "hold_${package}":
       ensure => 'absent',
     }
   }
index 597774c8338775a56e1e64c1d3a03ffe8ceb59ce..1c318b67ca979259ef79933b6b0faf2dedb85f7d 100644 (file)
@@ -139,19 +139,25 @@ class apt(
     default: { fail('Valid values for disable_keys are true or false') }
   }
 
-  $proxy_set = $proxy_host ? {
-    undef   => absent,
-    default => present
-  }
-
-  file { '01proxy':
-    ensure  => $proxy_set,
-    path    => "${apt_conf_d}/01proxy",
-    content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";\n",
-    notify  => Exec['apt_update'],
-    mode    => '0644',
-    owner   => root,
-    group   => root,
+  case $proxy_host {
+    false, '', undef: {
+      file { '01proxy':
+        ensure  => absent,
+        path    => "${apt_conf_d}/01proxy",
+        notify  => Exec['apt_update'],
+      }
+    }
+    default: {
+      file { '01proxy':
+        ensure  => present,
+        path    => "${apt_conf_d}/01proxy",
+        content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";\n",
+        notify  => Exec['apt_update'],
+        mode    => '0644',
+        owner   => root,
+        group   => root,
+      }
+    }
   }
 
   file { 'old-proxy-file':
index f635b5801cd98889582d19c088f6923a2708ace0..d57b80110c8209d4511a722120096a7ae721a4b2 100644 (file)
@@ -49,6 +49,9 @@ class apt::params {
         }
       }
     }
+    '': {
+      fail('Unable to determine lsbdistid, is lsb-release installed?')
+    }
     default: {
       fail("Unsupported lsbdistid (${::lsbdistid})")
     }
index a55e1e0e5c7a075b04ee4861370d40e107a42254..27edff80b21864539f1ca9eb86cfa6cc0f2a8979 100644 (file)
@@ -36,11 +36,13 @@ define apt::ppa(
     if defined(Class[apt]) {
         $proxy_host = $apt::proxy_host
         $proxy_port = $apt::proxy_port
-        case  $proxy_host {
-        false, '': {
+        case $proxy_host {
+          false, '', undef: {
             $proxy_env = []
-        }
-        default: {$proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]}
+          }
+          default: {
+            $proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]
+          }
         }
     } else {
         $proxy_env = []
index dd00adc6a4e62a6943cc5f0368596bd4d7c7ff4d..259d0ebb98993d26eacd83ce9db9cce2ac9012b3 100644 (file)
@@ -8,6 +8,7 @@ define apt::source(
   $release           = 'UNDEF',
   $repos             = 'main',
   $include_src       = true,
+  $include_deb       = true,
   $required_packages = false,
   $key               = undef,
   $key_server        = 'keyserver.ubuntu.com',
index 60def0e1544cd6ff86bc982bd36f6e25dc8d5b3d..97f00f1681abd418ebe5d00261b5d2556d7d5aef 100644 (file)
@@ -15,7 +15,7 @@ describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')
       EOS
 
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to match(/apt_update/)
+        expect(r.stdout).to match(/Exec\[apt_update\]/)
       end
     end
   end
@@ -26,7 +26,7 @@ describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')
       EOS
 
       apply_manifest(pp, :catch_failures => true) do |r|
-        expect(r.stdout).to_not match(/apt_update/)
+        expect(r.stdout).to_not match(/Exec\[apt_update\]/)
       end
     end
   end
index 6a19f4e74e044c5efb5eaf352340241fabd047b1..09f4e2bed09888036c9c7f6f2b54dbfd9b6c5c85 100644 (file)
@@ -10,8 +10,8 @@ describe 'apt::unattended_upgrades class', :unless => UNSUPPORTED_PLATFORMS.incl
 
       # Attempted workaround for problems seen on debian with
       # something holding the package database open.
-      #shell('killall -9 apt-get')
-      #shell('killall -9 dpkg')
+      shell('killall -9 apt-get', { :acceptable_exit_codes => [0,1] })
+      shell('killall -9 dpkg', { :acceptable_exit_codes => [0,1] })
       apply_manifest(pp, :catch_failures => true)
     end
 
index aa330bb987649ac03eeefc237164b09ad276d3ef..d85e849d5ae31a370ccce001f274f449608f32f9 100644 (file)
@@ -24,4 +24,16 @@ describe 'apt::params', :type => :class do
     end
 
   end
+
+  describe "With lsb-release not installed" do
+    let(:facts) { { :lsbdistid => '' } }
+    let (:title) { 'my_package' }
+
+    it do
+      expect {
+        should compile
+      }.to raise_error(Puppet::Error, /Unable to determine lsbdistid, is lsb-release installed/)
+    end
+  end
+
 end
index 731e218d84bc3dbf6e86838b2fda6874aa5871cb..9da21d784a9b634016bd49e3a2cebee9a2a94d08 100644 (file)
@@ -25,7 +25,7 @@ describe 'apt::hold' do
         :priority => 1001,
       })
 
-      should contain_apt__pin("hold #{title} at #{params[:version]}").with({
+      should contain_apt__pin("hold_#{title}").with({
         :ensure   => 'present',
         :packages => title,
         :version  => params[:version],
@@ -42,7 +42,7 @@ describe 'apt::hold' do
         :ensure   => params[:ensure],
       })
 
-      should contain_apt__pin("hold #{title} at #{params[:version]}").with({
+      should contain_apt__pin("hold_#{title}").with({
         :ensure   => params[:ensure],
       })
     end
@@ -59,7 +59,7 @@ describe 'apt::hold' do
         :priority => params[:priority],
       })
 
-      should contain_apt__pin("hold #{title} at #{params[:version]}").with({
+      should contain_apt__pin("hold_#{title}").with({
         :ensure   => 'present',
         :packages => title,
         :version  => params[:version],
index 7c7ae399e84768fe3d51daca47c67a49c35b8855..284adca27fe4496413607bdc0b638b127ee8d858 100644 (file)
@@ -15,6 +15,7 @@ describe 'apt::source', :type => :define do
       :release            => 'karmic',
       :repos              => 'main',
       :include_src        => true,
+      :include_deb        => true,
       :required_packages  => false,
       :key                => false,
       :key_server         => false,
@@ -83,8 +84,9 @@ describe 'apt::source', :type => :define do
         if param_hash[:architecture]
           arch = "[arch=#{param_hash[:architecture]}] "
         end
-        content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
-
+        if param_hash[:include_deb]
+         content << "\ndeb #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
+       end
         if param_hash[:include_src]
           content << "deb-src #{arch}#{param_hash[:location]} #{param_hash[:release]} #{param_hash[:repos]}\n"
         end
index a57244fce81e61be50470cdbdd7c39c741468312..01b2176a6ea5d0d357cb37444e4def4067111eb3 100644 (file)
@@ -1,6 +1,8 @@
 #file generated by puppet
 # <%= @comment %>
+<%- if @include_deb then -%>
 deb <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %>
+<%- end -%>
 <%- if @include_src then -%>
 deb-src <% if @architecture %>[arch=<%= @architecture %>] <% end %><%= @location %> <%= @release_real %> <%= @repos %>
 <%- end -%>