Fix inconsistent $proxy_host handling in apt and apt::ppa.
authorDaniel Friesen <daniel@nadir-seen-fire.com>
Thu, 10 Jul 2014 23:38:45 +0000 (16:38 -0700)
committerDaniel Friesen <daniel@nadir-seen-fire.com>
Thu, 10 Jul 2014 23:57:38 +0000 (16:57 -0700)
- The default for $proxy_host is undef
- apt considers $proxy_set to be absent if $proxy_host is undef
- apt::ppa considers proxy_env to be empty if $proxy_host is false or ''

This results in apt::ppa to consider $proxy_host to be set when the default undef is used
breaking ppa resources because $proxy_env becomes:
  [http_proxy=http://:8080, https_proxy=http://:8080]

Fix this by making both apt and apt::ppa consider $proxy_host to be unset when it is
any of false, '', or undef.

manifests/init.pp
manifests/ppa.pp

index 597774c8338775a56e1e64c1d3a03ffe8ceb59ce..08f62d15d950a171006cf9dbc94fc4e3f260544c 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",
+        content => "Acquire::http::Proxy \"http://${proxy_host}:${proxy_port}\";\n",
+        notify  => Exec['apt_update'],
+        mode    => '0644',
+        owner   => root,
+        group   => root,
+      }
+    }
+    default: {
+      file { '01proxy':
+        ensure  => present,
+        path    => "${apt_conf_d}/01proxy",
+        notify  => Exec['apt_update'],
+      }
+    }
   }
 
   file { 'old-proxy-file':
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 = []