Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Commit 3777199

Browse files
committed
Merge pull request #19 from wavesoftware/master
Add configuration parameter for allowing `curl` to follow redirects with `Location` HTTP header (default: true)
2 parents e2f5389 + 01baa95 commit 3777199

File tree

3 files changed

+41
-29
lines changed

3 files changed

+41
-29
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/metadata.json
2+
/.project

manifests/download.pp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
# - *$timeout: Default value 120.
1212
# - *$src_target: Default value '/usr/src'.
1313
# - *$allow_insecure: Default value false.
14+
# - *$allow_redirects: Default value true
1415
# - *$proxy: HTTP proxy in the form of "hostname:port"
1516
# - *$exec_path: Path being searched for all Exec resources, default: ['/usr/local/bin', '/usr/bin', '/bin']
1617
#
1718
# Example usage:
18-
19+
#
1920
# archive::download {'apache-tomcat-6.0.26.tar.gz':
2021
# ensure => present,
2122
# url => 'http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.26/bin/apache-tomcat-6.0.26.tar.gz',
@@ -29,18 +30,19 @@
2930
# }
3031
define archive::download (
3132
$url,
32-
$ensure = present,
33-
$checksum = true,
34-
$digest_url = '',
35-
$digest_string = '',
36-
$digest_type = 'md5',
37-
$timeout = 120,
38-
$src_target = '/usr/src',
39-
$allow_insecure = false,
40-
$username = undef,
41-
$password = undef,
42-
$proxy = undef,
43-
$exec_path = ['/usr/local/bin', '/usr/bin', '/bin']) {
33+
$ensure = present,
34+
$checksum = true,
35+
$digest_url = '',
36+
$digest_string = '',
37+
$digest_type = 'md5',
38+
$timeout = 120,
39+
$src_target = '/usr/src',
40+
$allow_insecure = false,
41+
$allow_redirects = true,
42+
$username = undef,
43+
$password = undef,
44+
$proxy = undef,
45+
$exec_path = ['/usr/local/bin', '/usr/bin', '/bin']) {
4446

4547
if ($username == undef and $password == undef) {
4648
$basic_auth = ''
@@ -59,6 +61,11 @@
5961
default => '',
6062
}
6163

64+
$redirects_arg = $allow_redirects ? {
65+
true => '-L',
66+
default => '',
67+
}
68+
6269
case $checksum {
6370
true : {
6471
case $digest_type {
@@ -84,7 +91,7 @@
8491
}
8592

8693
exec {"download digest of archive ${name}":
87-
command => "curl ${basic_auth} ${insecure_arg} ${proxy_arg} -L -s -o ${src_target}/${name}.${digest_type} ${digest_src}",
94+
command => "curl ${basic_auth} ${insecure_arg} ${redirects_arg} ${proxy_arg} -s -o ${src_target}/${name}.${digest_type} ${digest_src}",
8895
path => $exec_path,
8996
creates => "${src_target}/${name}.${digest_type}",
9097
timeout => $timeout,
@@ -141,7 +148,7 @@
141148
}
142149

143150
exec {"download archive ${name} and check sum":
144-
command => "curl ${basic_auth} -L -s ${insecure_arg} ${proxy_arg} -o ${src_target}/${name} ${url}",
151+
command => "curl ${basic_auth} -s ${insecure_arg} ${redirects_arg} ${proxy_arg} -o ${src_target}/${name} ${url}",
145152
path => $exec_path,
146153
creates => "${src_target}/${name}",
147154
logoutput => true,

manifests/init.pp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# - *$extension: Default value ".tar.gz"
1616
# - *$timeout: Default value 120
1717
# - *$allow_insecure: Default value false
18+
# - *$allow_redirects: Default value true
1819
# - *$strip_components: Strip the top most n directories from each file name; default value 0
1920
# - *$username: set basic auth username
2021
# - *$password: set basic auth password
@@ -50,6 +51,7 @@
5051
$extension = 'tar.gz',
5152
$src_target = '/usr/src',
5253
$allow_insecure = false,
54+
$allow_redirects = true,
5355
$strip_components = 0,
5456
$username = undef,
5557
$password = undef,
@@ -58,20 +60,21 @@
5860
$exec_path = ['/usr/local/bin', '/usr/bin', '/bin']) {
5961

6062
archive::download {"${name}.${extension}":
61-
ensure => $ensure,
62-
url => $url,
63-
checksum => $checksum,
64-
digest_url => $digest_url,
65-
digest_string => $digest_string,
66-
digest_type => $digest_type,
67-
timeout => $timeout,
68-
src_target => $src_target,
69-
allow_insecure => $allow_insecure,
70-
username => $username,
71-
password => $password,
72-
proxy => $proxy,
73-
require => $dependency_class,
74-
exec_path => $exec_path,
63+
ensure => $ensure,
64+
url => $url,
65+
checksum => $checksum,
66+
digest_url => $digest_url,
67+
digest_string => $digest_string,
68+
digest_type => $digest_type,
69+
timeout => $timeout,
70+
src_target => $src_target,
71+
allow_insecure => $allow_insecure,
72+
allow_redirects => $allow_redirects,
73+
username => $username,
74+
password => $password,
75+
proxy => $proxy,
76+
require => $dependency_class,
77+
exec_path => $exec_path,
7578
}
7679

7780
archive::extract { $name:

0 commit comments

Comments
 (0)