X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Farchive%2Fmanifests%2Fnexus.pp;fp=3rdparty%2Fmodules%2Farchive%2Fmanifests%2Fnexus.pp;h=65e22e562312e39ee066c8f80d90e38d58056959;hb=e107504bce7d9b21cc301124fc7c39fdb0762374;hp=0000000000000000000000000000000000000000;hpb=24caa46729f80fbba4be8b9b26ebcb3acc4cb0fb;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/archive/manifests/nexus.pp b/3rdparty/modules/archive/manifests/nexus.pp new file mode 100644 index 000000000..65e22e562 --- /dev/null +++ b/3rdparty/modules/archive/manifests/nexus.pp @@ -0,0 +1,114 @@ +# define: archive::nexus +# ====================== +# +# archive wrapper for downloading files from Nexus using REST API. Nexus API: +# https://repository.sonatype.org/nexus-restlet1x-plugin/default/docs/path__artifact_maven_content.html +# +# Parameters +# ---------- +# +# Examples +# -------- +# +# archive::nexus { '/tmp/jtstand-ui-0.98.jar': +# url => 'https://oss.sonatype.org', +# gav => 'org.codehaus.jtstand:jtstand-ui:0.98', +# repository => 'codehaus-releases', +# packaging => 'jar', +# extract => false, +# } +# +define archive::nexus ( + String $url, + String $gav, + String $repository, + Enum['present', 'absent'] $ensure = present, + Enum['none', 'md5', 'sha1', 'sha2','sha256', 'sha384', 'sha512'] $checksum_type = 'md5', + Boolean $checksum_verify = true, + String $packaging = 'jar', + Boolean $use_nexus3_urls = false, + Optional[String] $classifier = undef, + Optional[String] $extension = undef, + Optional[String] $username = undef, + Optional[String] $password = undef, + Optional[String] $user = undef, + Optional[String] $owner = undef, + Optional[String] $group = undef, + Optional[String] $mode = undef, + Optional[Boolean] $extract = undef, + Optional[String] $extract_path = undef, + Optional[String] $extract_flags = undef, + Optional[String] $extract_command = undef, + Optional[String] $creates = undef, + Optional[Boolean] $cleanup = undef, + Optional[String] $proxy_server = undef, + Optional[String] $proxy_type = undef, + Optional[Boolean] $allow_insecure = undef, +) { + + include ::archive::params + + $artifact_info = split($gav, ':') + + $group_id = $artifact_info[0] + $artifact_id = $artifact_info[1] + $version = $artifact_info[2] + + $query_params = { + + 'g' => $group_id, + 'a' => $artifact_id, + 'v' => $version, + 'r' => $repository, + 'p' => $packaging, + 'c' => $classifier, + 'e' => $extension, + + }.filter |$keys, $values| { $values != undef } + + if $use_nexus3_urls { + if $classifier { + $c = "-${classifier}" + } else { + $c = '' + } + $artifact_url = sprintf('%s/repository/%s/%s/%s/%s/%s-%s%s.%s', $url, + $repository, regsubst($group_id, '\.', '/', 'G'), $artifact_id, + $version, $artifact_id, $version, $c, $packaging) + $checksum_url = sprintf('%s.%s', $artifact_url, $checksum_type) + } else { + $artifact_url = assemble_nexus_url($url, $query_params) + $checksum_url = regsubst($artifact_url, "p=${packaging}", "p=${packaging}.${checksum_type}") + } + archive { $name: + ensure => $ensure, + source => $artifact_url, + username => $username, + password => $password, + checksum_url => $checksum_url, + checksum_type => $checksum_type, + checksum_verify => $checksum_verify, + extract => $extract, + extract_path => $extract_path, + extract_flags => $extract_flags, + extract_command => $extract_command, + user => $user, + group => $group, + creates => $creates, + cleanup => $cleanup, + proxy_server => $proxy_server, + proxy_type => $proxy_type, + allow_insecure => $allow_insecure, + } + + $file_owner = pick($owner, $archive::params::owner) + $file_group = pick($group, $archive::params::group) + $file_mode = pick($mode, $archive::params::mode) + + file { $name: + owner => $file_owner, + group => $file_group, + mode => $file_mode, + require => Archive[$name], + } +}