Mercurial > repos > other > Puppet
annotate modules/archive/manifests/go.pp @ 386:3fce34f642f1
Add a PHP module to handle platform differences
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 03 Jan 2022 17:09:39 +0000 |
parents | |
children | adf6fe9bbc17 |
rev | line source |
---|---|
386
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 # download from go |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 define archive::go ( |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 String $server, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 Integer $port, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 String $url_path, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 String $md5_url_path, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 String $username, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 String $password, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 Enum['present', 'absent'] $ensure = present, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 String $path = $name, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 Optional[String] $owner = undef, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 Optional[String] $group = undef, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 Optional[String] $mode = undef, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 Optional[Boolean] $extract = undef, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 Optional[String] $extract_path = undef, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 Optional[String] $creates = undef, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 Optional[Boolean] $cleanup = undef, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 Optional[Stdlib::Compat::Absolute_path] $archive_path = undef, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 ) { |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 include archive::params |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 if $archive_path { |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 $file_path = "${archive_path}/${name}" |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 } else { |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 $file_path = $path |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 } |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 if $file_path !~ Stdlib::Compat::Absolute_path { |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 fail("archive::go[${name}]: \$name or \$archive_path must be an absolute path!") # lint:ignore:trailing_comma |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 } |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 $go_url = "http://${server}:${port}" |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 $file_url = "${go_url}/${url_path}" |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
34 $md5_url = "${go_url}/${md5_url_path}" |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
36 archive { $file_path: |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 ensure => $ensure, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 path => $file_path, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 extract => $extract, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
40 extract_path => $extract_path, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
41 source => $file_url, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
42 checksum => archive::go_md5($username, $password, $name, $md5_url), |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
43 checksum_type => 'md5', |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
44 creates => $creates, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
45 cleanup => $cleanup, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
46 username => $username, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
47 password => $password, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
48 } |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
49 |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
50 $file_owner = pick($owner, $archive::params::owner) |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
51 $file_group = pick($group, $archive::params::group) |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
52 $file_mode = pick($mode, $archive::params::mode) |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
53 |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
54 file { $file_path: |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
55 owner => $file_owner, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
56 group => $file_group, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
57 mode => $file_mode, |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
58 require => Archive[$file_path], |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
59 } |
3fce34f642f1
Add a PHP module to handle platform differences
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
60 } |