Skip to content

Commit

Permalink
Merge pull request #144 from hunner/ppa_proxy
Browse files Browse the repository at this point in the history
Ppa proxy
  • Loading branch information
hunner committed Jul 12, 2013
2 parents 0e374f0 + 4d8a99a commit 62e7faf
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
13 changes: 13 additions & 0 deletions manifests/ppa.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,20 @@
package { $package: }
}

if defined(Class[apt]) {
$proxy_host = getparam(Class[apt], "proxy_host")
$proxy_port = getparam(Class[apt], "proxy_port")
case $proxy_host {
false: {
$proxy_env = ""
}
default: {$proxy_env = ["http_proxy=http://${proxy_host}:${proxy_port}", "https_proxy=http://${proxy_host}:${proxy_port}"]}
}
} else {
$proxy_env = ""
}
exec { "add-apt-repository-${name}":
environment => $proxy_env,
command => "/usr/bin/add-apt-repository ${name}",
creates => "${sources_list_d}/${sources_list_d_filename}",
logoutput => 'on_failure',
Expand Down
25 changes: 25 additions & 0 deletions spec/defines/ppa_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,31 @@
}
end
end
describe 'behind a proxy' do
let :title do
'rspec_ppa'
end
let :pre_condition do
'class { "apt":
proxy_host => "user:pass@proxy",
}'
end
let :filename do
"#{title}-#{release}.list"
end

it { should contain_exec("add-apt-repository-#{title}").with(
'environment' => [
"http_proxy=http://user:pass@proxy:8080",
"https_proxy=http://user:pass@proxy:8080",
],
'command' => "/usr/bin/add-apt-repository #{title}",
'creates' => "/etc/apt/sources.list.d/#{filename}",
'require' => ["File[/etc/apt/sources.list.d]", "Package[#{package}]"],
'notify' => "Exec[apt_update]"
)
}
end
end
end

Expand Down

0 comments on commit 62e7faf

Please sign in to comment.