Add puppet/archive module
[mirror/dsa-puppet.git] / 3rdparty / modules / archive / manifests / go.pp
1 # download from go
2 define archive::go (
3   String                    $server,
4   Integer                   $port,
5   String                    $url_path,
6   String                    $md5_url_path,
7   String                    $username,
8   String                    $password,
9   Enum['present', 'absent'] $ensure       = present,
10   String                    $path         = $name,
11   Optional[String]          $owner        = undef,
12   Optional[String]          $group        = undef,
13   Optional[String]          $mode         = undef,
14   Optional[Boolean]         $extract      = undef,
15   Optional[String]          $extract_path = undef,
16   Optional[String]          $creates      = undef,
17   Optional[Boolean]         $cleanup      = undef,
18   Optional[Stdlib::Compat::Absolute_path] $archive_path = undef,
19 ) {
20
21   include ::archive::params
22
23   if $archive_path {
24     $file_path = "${archive_path}/${name}"
25   } else {
26     $file_path = $path
27   }
28
29   if $file_path !~ Stdlib::Compat::Absolute_path {
30     fail("archive::go[${name}]: \$name or \$archive_path must be an absolute path!") # lint:ignore:trailing_comma
31   }
32
33   $go_url = "http://${server}:${port}"
34   $file_url = "${go_url}/${url_path}"
35   $md5_url = "${go_url}/${md5_url_path}"
36
37   archive { $file_path:
38     ensure        => $ensure,
39     path          => $file_path,
40     extract       => $extract,
41     extract_path  => $extract_path,
42     source        => $file_url,
43     checksum      => go_md5($username, $password, $name, $md5_url),
44     checksum_type => 'md5',
45     creates       => $creates,
46     cleanup       => $cleanup,
47     username      => $username,
48     password      => $password,
49   }
50
51   $file_owner = pick($owner, $archive::params::owner)
52   $file_group = pick($group, $archive::params::group)
53   $file_mode  = pick($mode, $archive::params::mode)
54
55   file { $file_path:
56     owner   => $file_owner,
57     group   => $file_group,
58     mode    => $file_mode,
59     require => Archive[$file_path],
60   }
61 }