|
11 | 11 | # - *$timeout: Default value 120. |
12 | 12 | # - *$src_target: Default value '/usr/src'. |
13 | 13 | # - *$allow_insecure: Default value false. |
| 14 | +# - *$allow_redirects: Default value true |
14 | 15 | # - *$proxy: HTTP proxy in the form of "hostname:port" |
15 | 16 | # - *$exec_path: Path being searched for all Exec resources, default: ['/usr/local/bin', '/usr/bin', '/bin'] |
16 | 17 | # |
17 | 18 | # Example usage: |
18 | | - |
| 19 | +# |
19 | 20 | # archive::download {'apache-tomcat-6.0.26.tar.gz': |
20 | 21 | # ensure => present, |
21 | 22 | # url => 'http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.26/bin/apache-tomcat-6.0.26.tar.gz', |
|
29 | 30 | # } |
30 | 31 | define archive::download ( |
31 | 32 | $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']) { |
44 | 46 |
|
45 | 47 | if ($username == undef and $password == undef) { |
46 | 48 | $basic_auth = '' |
|
59 | 61 | default => '', |
60 | 62 | } |
61 | 63 |
|
| 64 | + $redirects_arg = $allow_redirects ? { |
| 65 | + true => '-L', |
| 66 | + default => '', |
| 67 | + } |
| 68 | + |
62 | 69 | case $checksum { |
63 | 70 | true : { |
64 | 71 | case $digest_type { |
|
84 | 91 | } |
85 | 92 |
|
86 | 93 | 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}", |
88 | 95 | path => $exec_path, |
89 | 96 | creates => "${src_target}/${name}.${digest_type}", |
90 | 97 | timeout => $timeout, |
|
141 | 148 | } |
142 | 149 |
|
143 | 150 | 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}", |
145 | 152 | path => $exec_path, |
146 | 153 | creates => "${src_target}/${name}", |
147 | 154 | logoutput => true, |
|
0 commit comments