Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to download with user. #8

Merged
merged 1 commit into from
May 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
################################################################################
class wget($version='installed') {

if $::operatingsystem != 'Darwin' {
package { "wget": ensure => $version }
}
Expand All @@ -18,7 +18,7 @@
# using $http_proxy if necessary.
#
################################################################################
define wget::fetch($source,$destination,$timeout="0",$verbose=false,$redownload=false,$nocheckcertificate=false) {
define wget::fetch($source,$destination,$timeout="0",$verbose=false,$redownload=false,$nocheckcertificate=false,$user='root') {
include wget
# using "unless" with test instead of "creates" to re-attempt download
# on empty files.
Expand All @@ -40,17 +40,18 @@
true => "test",
false => "test -s $destination"
}

$nocheckcert_option = $nocheckcertificate ? {
true => ' --no-check-certificate',
false => ''
}

exec { "wget-$name":
command => "wget $verbose_option$nocheckcert_option --output-document=$destination $source",
timeout => $timeout,
unless => $unless_test,
environment => $environment,
user => $user,
path => "/usr/bin:/usr/sbin:/bin:/usr/local/bin:/opt/local/bin",
require => Class[wget],
}
Expand Down Expand Up @@ -82,25 +83,25 @@
true => "test",
false => "test -s $destination"
}

$nocheckcert_option = $nocheckcertificate ? {
true => ' --no-check-certificate',
false => ''
}

case $::operatingsystem {
'Darwin': {
# This is to work around an issue with macports wget and out of date CA cert bundle. This requires
# This is to work around an issue with macports wget and out of date CA cert bundle. This requires
# installing the curl-ca-bundle package like so:
#
# sudo port install curl-ca-bundle
# sudo port install curl-ca-bundle
$wgetrc_content = "password=$password\nCA_CERTIFICATE=/opt/local/share/curl/curl-ca-bundle.crt\n"
}
}
default: {
$wgetrc_content = "password=$password"
}
}

file { "/tmp/wgetrc-$name":
owner => root,
mode => 600,
Expand Down
6 changes: 5 additions & 1 deletion spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
end

describe 'wget::fetch' do
it { should contain_exec('wget-test').with_command('wget --no-verbose --output-document=/tmp/dest http://localhost/source') }
it { should contain_exec('wget-test').with({
'command' => 'wget --no-verbose --output-document=/tmp/dest http://localhost/source',
'user' => 'testuser'
})
}
end

describe 'wget::authfetch' do
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/manifests/site.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
wget::fetch { 'test':
source => 'http://localhost/source',
destination => '/tmp/dest',
user => 'testuser',
}

wget::authfetch { 'authtest':
Expand Down