Skip to content

Commit

Permalink
Fix inconsistent $proxy_host handling in apt and apt::ppa.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
dantman committed Jul 10, 2014
1 parent 06b5dc2 commit 0c2329b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
32 changes: 19 additions & 13 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,25 @@
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':
Expand Down
10 changes: 6 additions & 4 deletions manifests/ppa.pp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@
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 = []
Expand Down

0 comments on commit 0c2329b

Please sign in to comment.