]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge pull request #443 from mhaskel/proxy_updates
authorDaniele Sluijters <daenney@users.noreply.github.com>
Thu, 26 Feb 2015 17:00:17 +0000 (18:00 +0100)
committerDaniele Sluijters <daenney@users.noreply.github.com>
Thu, 26 Feb 2015 17:00:17 +0000 (18:00 +0100)
proxy_* params were removed from class apt

examples/proxy.pp [new file with mode: 0644]
manifests/params.pp
manifests/ppa.pp
spec/defines/ppa_spec.rb

diff --git a/examples/proxy.pp b/examples/proxy.pp
new file mode 100644 (file)
index 0000000..4640904
--- /dev/null
@@ -0,0 +1 @@
+# TODO
index 8f9d7e85f48f4a2025f6e6c4943f2529493de1ad..3c169e3fcfa8c05a32e395f0fee531f9dd6ae8fc 100644 (file)
@@ -31,6 +31,11 @@ class apt::params {
     }
   }
 
+  $proxy = {
+    'host' => undef,
+    'port' => 8080,
+  }
+
   $file_defaults = {
     'owner' => 'root',
     'group' => 'root',
index 4181b5811d3686fa4f0f9744e2f1d289a7913023..1dc8e26fce80519d67c00c21cb16c894f00b029b 100644 (file)
@@ -5,6 +5,7 @@ define apt::ppa(
   $options        = $::apt::ppa_options,
   $package_name   = $::apt::ppa_package,
   $package_manage = false,
+  $proxy          = {},
 ) {
   if ! $release {
     fail('lsbdistcodename fact not available: release parameter required')
@@ -19,6 +20,8 @@ define apt::ppa(
   $filename_without_ppa     = regsubst($filename_without_dots, '^ppa:', '', 'G')
   $sources_list_d_filename  = "${filename_without_ppa}-${release}.list"
 
+  $_proxy = merge($apt::proxy, $proxy)
+
   if $ensure == 'present' {
     if $package_manage {
       package { $package_name: }
@@ -28,12 +31,12 @@ define apt::ppa(
       $_require = File['sources.list.d']
     }
 
-    case $::apt::proxy_host {
+    case $_proxy['host'] {
       false, '', undef: {
         $_proxy_env = []
       }
       default: {
-        $_proxy_env = ["http_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}", "https_proxy=http://${::apt::proxy_host}:${::apt::proxy_port}"]
+        $_proxy_env = ["http_proxy=http://${_proxy['host']}:${_proxy['port']}", "https_proxy=http://${_proxy['host']}:${_proxy['port']}"]
       }
     }
 
index f3c76a3bde3facefa498e71c4a41ced6724a0d12..6ca008b4ba8399919d8b368568c90259c46322d2 100644 (file)
@@ -58,6 +58,70 @@ describe 'apt::ppa', :type => :define do
     }
   end
 
+  describe 'apt included, proxy host' do
+    let :pre_condition do
+      'class { "apt": }'
+    end
+    let :facts do
+      {
+        :lsbdistrelease  => '14.04',
+        :lsbdistcodename => 'trusty',
+        :operatingsystem => 'Ubuntu',
+        :lsbdistid       => 'Ubuntu',
+        :osfamily        => 'Debian',
+      }
+    end
+    let :params do
+      {
+        'options' => '',
+        'package_manage' => true,
+        'proxy' => { 'host' => 'localhost', }
+      }
+    end
+    let(:title) { 'ppa:foo' }
+    it { is_expected.to contain_package('software-properties-common') }
+    it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
+      'environment' => ['http_proxy=http://localhost:8080', 'https_proxy=http://localhost:8080'],
+      'command'     => '/usr/bin/add-apt-repository  ppa:foo',
+      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
+      'user'        => 'root',
+      'logoutput'   => 'on_failure',
+    })
+    }
+  end
+
+  describe 'apt included, proxy host and port' do
+    let :pre_condition do
+      'class { "apt": }'
+    end
+    let :facts do
+      {
+        :lsbdistrelease  => '14.04',
+        :lsbdistcodename => 'trusty',
+        :operatingsystem => 'Ubuntu',
+        :lsbdistid       => 'Ubuntu',
+        :osfamily        => 'Debian',
+      }
+    end
+    let :params do
+      {
+        'options' => '',
+        'package_manage' => true,
+        'proxy' => { 'host' => 'localhost', 'port' => 8180, }
+      }
+    end
+    let(:title) { 'ppa:foo' }
+    it { is_expected.to contain_package('software-properties-common') }
+    it { is_expected.to contain_exec('add-apt-repository-ppa:foo').that_notifies('Exec[apt_update]').with({
+      'environment' => ['http_proxy=http://localhost:8180', 'https_proxy=http://localhost:8180'],
+      'command'     => '/usr/bin/add-apt-repository  ppa:foo',
+      'unless'      => '/usr/bin/test -s /etc/apt/sources.list.d/foo-trusty.list',
+      'user'        => 'root',
+      'logoutput'   => 'on_failure',
+    })
+    }
+  end
+
   describe 'ensure absent' do
     let :pre_condition do
       'class { "apt": }'