1 # define: archive::nexus
2 # ======================
4 # archive wrapper for downloading files from Nexus using REST API. Nexus API:
5 # https://repository.sonatype.org/nexus-restlet1x-plugin/default/docs/path__artifact_maven_content.html
13 # archive::nexus { '/tmp/jtstand-ui-0.98.jar':
14 # url => 'https://oss.sonatype.org',
15 # gav => 'org.codehaus.jtstand:jtstand-ui:0.98',
16 # repository => 'codehaus-releases',
21 define archive::nexus (
25 Enum['present', 'absent'] $ensure = present,
26 Enum['none', 'md5', 'sha1', 'sha2','sha256', 'sha384', 'sha512'] $checksum_type = 'md5',
27 Boolean $checksum_verify = true,
28 String $packaging = 'jar',
29 Boolean $use_nexus3_urls = false,
30 Optional[String] $classifier = undef,
31 Optional[String] $extension = undef,
32 Optional[String] $username = undef,
33 Optional[String] $password = undef,
34 Optional[String] $user = undef,
35 Optional[String] $owner = undef,
36 Optional[String] $group = undef,
37 Optional[String] $mode = undef,
38 Optional[Boolean] $extract = undef,
39 Optional[String] $extract_path = undef,
40 Optional[String] $extract_flags = undef,
41 Optional[String] $extract_command = undef,
42 Optional[String] $creates = undef,
43 Optional[Boolean] $cleanup = undef,
44 Optional[String] $proxy_server = undef,
45 Optional[String] $proxy_type = undef,
46 Optional[Boolean] $allow_insecure = undef,
49 include ::archive::params
51 $artifact_info = split($gav, ':')
53 $group_id = $artifact_info[0]
54 $artifact_id = $artifact_info[1]
55 $version = $artifact_info[2]
67 }.filter |$keys, $values| { $values != undef }
75 $artifact_url = sprintf('%s/repository/%s/%s/%s/%s/%s-%s%s.%s', $url,
76 $repository, regsubst($group_id, '\.', '/', 'G'), $artifact_id,
77 $version, $artifact_id, $version, $c, $packaging)
78 $checksum_url = sprintf('%s.%s', $artifact_url, $checksum_type)
80 $artifact_url = assemble_nexus_url($url, $query_params)
81 $checksum_url = regsubst($artifact_url, "p=${packaging}", "p=${packaging}.${checksum_type}")
85 source => $artifact_url,
86 username => $username,
87 password => $password,
88 checksum_url => $checksum_url,
89 checksum_type => $checksum_type,
90 checksum_verify => $checksum_verify,
92 extract_path => $extract_path,
93 extract_flags => $extract_flags,
94 extract_command => $extract_command,
99 proxy_server => $proxy_server,
100 proxy_type => $proxy_type,
101 allow_insecure => $allow_insecure,
104 $file_owner = pick($owner, $archive::params::owner)
105 $file_group = pick($group, $archive::params::group)
106 $file_mode = pick($mode, $archive::params::mode)
109 owner => $file_owner,
110 group => $file_group,
112 require => Archive[$name],