Merge pull request #145 from PierreGambarotto/master
authorHunter Haugen <h.haugen@gmail.com>
Wed, 31 Jul 2013 16:32:27 +0000 (09:32 -0700)
committerHunter Haugen <h.haugen@gmail.com>
Wed, 31 Jul 2013 16:32:27 +0000 (09:32 -0700)
ppa: fix empty environment definition in exec ressource when no proxy

manifests/ppa.pp
spec/defines/ppa_spec.rb

index 6cb921f19bec95951ff52a554b0f8cb096f4ed39..92b6c0e0b28e131af31b3d0903d6de1882aca896 100644 (file)
@@ -1,7 +1,8 @@
 # ppa.pp
 
 define apt::ppa(
-  $release = $::lsbdistcodename
+  $release = $::lsbdistcodename,
+  $options = "-y"
 ) {
   include apt::params
   include apt::update
@@ -12,9 +13,9 @@ define apt::ppa(
     fail('lsbdistcodename fact not available: release parameter required')
   }
 
-  $filename_without_slashes = regsubst($name, '/', '-', G)
-  $filename_without_dots    = regsubst($filename_without_slashes, '\.', '_', G)
-  $filename_without_ppa     = regsubst($filename_without_dots, '^ppa:', '', G)
+  $filename_without_slashes = regsubst($name, '/', '-', 'G')
+  $filename_without_dots    = regsubst($filename_without_slashes, '\.', '_', 'G')
+  $filename_without_ppa     = regsubst($filename_without_dots, '^ppa:', '', 'G')
   $sources_list_d_filename  = "${filename_without_ppa}-${release}.list"
 
   $package = $::lsbdistrelease ? {
@@ -40,7 +41,7 @@ define apt::ppa(
   }
   exec { "add-apt-repository-${name}":
     environment  => $proxy_env,
-    command   => "/usr/bin/add-apt-repository ${name}",
+    command   => "/usr/bin/add-apt-repository ${options} ${name}",
     creates   => "${sources_list_d}/${sources_list_d_filename}",
     logoutput => 'on_failure',
     require   => [
index b768b25d3fbf9ca899b3c48a5c7b3c14f584666e..ae91e585faec0fed07290a0efbdd82b27435ff46 100644 (file)
@@ -20,6 +20,9 @@ describe 'apt::ppa', :type => :define do
       let :package do
         "#{platform[:package]}"
       end
+      let :options do
+        "-y"
+      end
       ['ppa:dans_ppa', 'dans_ppa','ppa:dans-daily/ubuntu'].each do |t|
         describe "with title #{t}" do
           let :pre_condition do
@@ -41,7 +44,7 @@ describe 'apt::ppa', :type => :define do
           }
 
           it { should contain_exec("add-apt-repository-#{t}").with(
-            'command' => "/usr/bin/add-apt-repository #{t}",
+            'command' => "/usr/bin/add-apt-repository #{options} #{t}",
             'creates' => "/etc/apt/sources.list.d/#{filename}",
             'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
             'notify'  => "Exec[apt_update]"
@@ -96,7 +99,7 @@ describe 'apt::ppa', :type => :define do
             "http_proxy=http://user:pass@proxy:8080",
             "https_proxy=http://user:pass@proxy:8080",
           ],
-          'command'     => "/usr/bin/add-apt-repository #{title}",
+          'command'     => "/usr/bin/add-apt-repository #{options} #{title}",
           'creates'     => "/etc/apt/sources.list.d/#{filename}",
           'require'     => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
           'notify'      => "Exec[apt_update]"