diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/archive/manifests/go.pp	Mon Jan 03 17:09:39 2022 +0000
@@ -0,0 +1,60 @@
+# download from go
+define archive::go (
+  String                    $server,
+  Integer                   $port,
+  String                    $url_path,
+  String                    $md5_url_path,
+  String                    $username,
+  String                    $password,
+  Enum['present', 'absent'] $ensure       = present,
+  String                    $path         = $name,
+  Optional[String]          $owner        = undef,
+  Optional[String]          $group        = undef,
+  Optional[String]          $mode         = undef,
+  Optional[Boolean]         $extract      = undef,
+  Optional[String]          $extract_path = undef,
+  Optional[String]          $creates      = undef,
+  Optional[Boolean]         $cleanup      = undef,
+  Optional[Stdlib::Compat::Absolute_path] $archive_path = undef,
+) {
+  include archive::params
+
+  if $archive_path {
+    $file_path = "${archive_path}/${name}"
+  } else {
+    $file_path = $path
+  }
+
+  if $file_path !~ Stdlib::Compat::Absolute_path {
+    fail("archive::go[${name}]: \$name or \$archive_path must be an absolute path!") # lint:ignore:trailing_comma
+  }
+
+  $go_url = "http://${server}:${port}"
+  $file_url = "${go_url}/${url_path}"
+  $md5_url = "${go_url}/${md5_url_path}"
+
+  archive { $file_path:
+    ensure        => $ensure,
+    path          => $file_path,
+    extract       => $extract,
+    extract_path  => $extract_path,
+    source        => $file_url,
+    checksum      => archive::go_md5($username, $password, $name, $md5_url),
+    checksum_type => 'md5',
+    creates       => $creates,
+    cleanup       => $cleanup,
+    username      => $username,
+    password      => $password,
+  }
+
+  $file_owner = pick($owner, $archive::params::owner)
+  $file_group = pick($group, $archive::params::group)
+  $file_mode  = pick($mode, $archive::params::mode)
+
+  file { $file_path:
+    owner   => $file_owner,
+    group   => $file_group,
+    mode    => $file_mode,
+    require => Archive[$file_path],
+  }
+}