Mercurial > repos > other > Puppet
comparison modules/archive/manifests/download.pp @ 478:adf6fe9bbc17
Update Puppet modules to latest versions
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 29 Aug 2024 18:47:29 +0100 |
parents | 3fce34f642f1 |
children |
comparison
equal
deleted
inserted
replaced
477:21f6add30502 | 478:adf6fe9bbc17 |
---|---|
1 # == Definition: archive::download | |
2 # | 1 # |
3 # Archive downloader with integrity verification. | 2 # @summary Archive downloader with integrity verification |
4 # | 3 # |
5 # Parameters: | 4 # @param url |
5 # source | |
6 # @param headers | |
7 # HTTP (s) to pass to source | |
8 # @param allow_insecure | |
9 # Allow self-signed certificate on source? | |
10 # @param checksum | |
11 # Should checksum be validated? | |
12 # @param digest_type | |
13 # Digest to use for calculating checksum | |
14 # @param ensure | |
15 # ensure file present/absent | |
16 # @param src_target | |
17 # Absolute path to staging location | |
18 # @param digest_string | |
19 # Value expected checksum | |
20 # @param digest_url | |
21 # URL expected checksum value | |
22 # @param proxy_server | |
23 # FQDN of proxy server | |
24 # @param user | |
25 # User used to download the archive | |
6 # | 26 # |
7 # - *$url: | 27 # @example |
8 # - *$digest_url: | 28 # archive::download {"apache-tomcat-6.0.26.tar.gz": |
9 # - *$digest_string: Default value undef | 29 # ensure => present, |
10 # - *$digest_type: Default value "md5". | 30 # url => "http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.26/bin/apache-tomcat-6.0.26.tar.gz", |
11 # - *$timeout: Default value 120. (ignored) | 31 # } |
12 # - *$src_target: Default value "/usr/src". | 32 # @example |
13 # - *$allow_insecure: Default value false. | 33 # archive::download {"apache-tomcat-6.0.26.tar.gz": |
14 # - *$follow_redirects: Default value false. | 34 # ensure => present, |
15 # - *$verbose: Default value true. | 35 # digest_string => "f9eafa9bfd620324d1270ae8f09a8c89", |
16 # - *$proxy_server: Default value undef. | 36 # url => "http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.26/bin/apache-tomcat-6.0.26.tar.gz", |
17 # - *$user: The user used to download the archive | 37 # } |
18 # | |
19 # Example usage: | |
20 # | |
21 # archive::download {"apache-tomcat-6.0.26.tar.gz": | |
22 # ensure => present, | |
23 # url => "http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.26/bin/apache-tomcat-6.0.26.tar.gz", | |
24 # } | |
25 # | |
26 # archive::download {"apache-tomcat-6.0.26.tar.gz": | |
27 # ensure => present, | |
28 # digest_string => "f9eafa9bfd620324d1270ae8f09a8c89", | |
29 # url => "http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.26/bin/apache-tomcat-6.0.26.tar.gz", | |
30 # } | |
31 # | 38 # |
32 define archive::download ( | 39 define archive::download ( |
33 String $url, | 40 String $url, |
34 Enum['present', 'absent'] $ensure = present, | 41 Array $headers = [], |
35 Boolean $checksum = true, | 42 Boolean $allow_insecure = false, |
36 Optional[String] $digest_url = undef, | 43 Boolean $checksum = true, |
37 Optional[String] $digest_string = undef, | |
38 Enum['none', 'md5', 'sha1', 'sha2','sha256', 'sha384', 'sha512'] $digest_type = 'md5', # bad default! | 44 Enum['none', 'md5', 'sha1', 'sha2','sha256', 'sha384', 'sha512'] $digest_type = 'md5', # bad default! |
39 Integer $timeout = 120, # ignored | 45 Enum['present', 'absent'] $ensure = 'present', |
40 Stdlib::Compat::Absolute_path $src_target = '/usr/src', | 46 Stdlib::Absolutepath $src_target = '/usr/src', |
41 Boolean $allow_insecure = false, | 47 Optional[String] $digest_string = undef, |
42 Boolean $follow_redirects = false, # ignored (default) | 48 Optional[String] $digest_url = undef, |
43 Boolean $verbose = true, # ignored | 49 Optional[String] $proxy_server = undef, |
44 String $path = $facts['path'], # ignored | 50 Optional[String] $user = undef, |
45 Optional[String] $proxy_server = undef, | |
46 Optional[String] $user = undef, | |
47 ) { | 51 ) { |
48 $target = ($title =~ Stdlib::Compat::Absolute_path) ? { | 52 $target = ($title =~ Stdlib::Absolutepath) ? { |
49 false => "${src_target}/${title}", | 53 false => "${src_target}/${title}", |
50 default => $title, | 54 default => $title, |
51 } | 55 } |
52 | 56 |
53 archive { $target: | 57 archive { $target: |
57 checksum => $digest_string, | 61 checksum => $digest_string, |
58 checksum_type => $digest_type, | 62 checksum_type => $digest_type, |
59 checksum_url => $digest_url, | 63 checksum_url => $digest_url, |
60 proxy_server => $proxy_server, | 64 proxy_server => $proxy_server, |
61 user => $user, | 65 user => $user, |
66 headers => $headers, | |
62 allow_insecure => $allow_insecure, | 67 allow_insecure => $allow_insecure, |
63 } | 68 } |
64 } | 69 } |