From 0c2329bd57c383a1562cad474284dbf28c15d234 Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Thu, 10 Jul 2014 16:38:45 -0700 Subject: [PATCH] Fix inconsistent $proxy_host handling in apt and apt::ppa. - 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 | 32 +++++++++++++++++++------------- manifests/ppa.pp | 10 ++++++---- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 597774c..08f62d1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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': diff --git a/manifests/ppa.pp b/manifests/ppa.pp index a55e1e0..27edff8 100644 --- a/manifests/ppa.pp +++ b/manifests/ppa.pp @@ -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 = [] -- 2.32.3