Skip to content

Commit

Permalink
Release v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TuningYourCode committed Jan 18, 2022
1 parent 079e609 commit 5a6b7c1
Show file tree
Hide file tree
Showing 16 changed files with 131 additions and 172 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file.

## 2.0.0
* Change http download urls to https
* Change from params.pp pattern to hiera lookup
* Add proper data types for module parameter
* Change nexus_port from data type string to integer (Stdlib::Port)
* Drop `version` parameter from `nexus::service` class as it is not used
* Drop `md5sum` parameter from `nexus` class as it is not used (checksum source depends on download url)
* Drop Nexus Repository Manager 2 example - next major version will drop support for that version
* Drop support for end of life puppet versions

## 1.9.2
* Allow proxy use to download the archive

Expand Down
41 changes: 12 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,34 @@
# Sonatype Nexus Puppet module
# Sonatype Nexus Repository Manager Puppet module
Install and configure Sonatype Nexus.

This module was forked from [hubspot/nexus](https://forge.puppet.com/hubspot/nexus).

## Requires
## Requirements of this module
* puppet/archive
* puppetlabs/stdlib

## Usage
The following is a basic role class for building a nexus host. Adjust
accordingly as needed.

NOTE: you must pass version to Class['nexus']. This is needed for the
NOTE: you must pass version to `Class['nexus']`. This is needed for the
download link and determining the name of the nexus directory.

```puppet
class role_nexus_server {
# puppetlabs-java
# NOTE: Nexus requires
class{ '::java': }
class{ '::nexus':
version => '2.8.0',
revision => '05',
nexus_root => '/srv', # All directories and files will be relative to this
}
Class['::java'] ->
Class['::nexus']
}
```

NOTE: If you wish to deploy a Nexus Pro server instead of Nexus OSS set
`deploy_pro => true`

### Usage

```puppet
class role_nexus_server {
class{ '::nexus':
version => '3.34.1',
revision => '01',
download_site => 'https://download.sonatype.com/nexus/3',
class{ 'java': }
class{ 'nexus':
version => '3.37.3',
revision => '02',
nexus_type => 'unix',
}
Class['java'] ->
Class['nexus']
}
```
Expand Down
23 changes: 23 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
nexus::deploy_pro: false
nexus::download_folder: /srv
nexus::download_proxy: null
nexus::download_site: https://download.sonatype.com/nexus/oss
nexus::manage_config: true
nexus::nexus_context: /nexus
nexus::nexus_data_folder: null
nexus::nexus_group: nexus
nexus::nexus_home_dir: nexus
nexus::nexus_host: 0.0.0.0
nexus::nexus_manage_user: true
nexus::nexus_port: 8081
nexus::nexus_root: /srv
nexus::nexus_selinux_ignore_defaults: true
nexus::nexus_type: bundle
nexus::nexus_user: nexus
nexus::nexus_work_dir: null
nexus::nexus_work_dir_manage: true
nexus::nexus_work_recurse: true
nexus::pro_download_site: https://download.sonatype.com/nexus/professional-bundle
nexus::revision: '01'
nexus::version: latest
21 changes: 21 additions & 0 deletions hiera.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
version: 5

defaults: # Used for any hierarchy level that omits these keys.
datadir: data # This path is relative to hiera.yaml's directory.
data_hash: yaml_data # Use the built-in YAML backend.

hierarchy:
- name: "osfamily/major release"
paths:
# Used to distinguish between Debian and Ubuntu
- "os/%{facts.os.name}/%{facts.os.release.major}.yaml"
- "os/%{facts.os.family}/%{facts.os.release.major}.yaml"
# Used for Solaris
- "os/%{facts.os.family}/%{facts.kernelrelease}.yaml"
- name: "osfamily"
paths:
- "os/%{facts.os.name}.yaml"
- "os/%{facts.os.family}.yaml"
- name: 'common'
path: 'common.yaml'
21 changes: 10 additions & 11 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@
#
# Copyright 2013 Hubspot
#
class nexus::config(
$nexus_root = $::nexus::nexus_root,
$nexus_home_dir = $::nexus::nexus_home_dir,
$nexus_host = $::nexus::nexus_host,
$nexus_port = $::nexus::nexus_port,
$nexus_context = $::nexus::nexus_context,
$nexus_work_dir = $::nexus::nexus_work_dir,
$nexus_data_folder = $::nexus::nexus_data_folder,
$version = $::nexus::version,
class nexus::config (
Stdlib::Absolutepath $nexus_root = $::nexus::nexus_root,
String[1] $nexus_home_dir = $::nexus::nexus_home_dir,
Stdlib::Host $nexus_host = $::nexus::nexus_host,
Stdlib::Port $nexus_port = $::nexus::nexus_port,
String[1] $nexus_context = $::nexus::nexus_context,
Optional[Stdlib::Absolutepath] $nexus_work_dir = $::nexus::nexus_work_dir,
Optional[Stdlib::Absolutepath] $nexus_data_folder = $::nexus::nexus_data_folder,
Pattern[/\d+.\d+.\d+/] $version = $::nexus::version,
) {

if $version !~ /\d.*/ or versioncmp($version, '3.1.0') >= 0 {
if versioncmp($version, '3.1.0') >= 0 {
# Per the Sonatype documentation the custom nexus properties file is
# {karaf.data}/etc/nexus.properties where {karaf.data} is the work dir
$conf_path = 'etc/nexus.properties'
Expand Down
64 changes: 25 additions & 39 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,56 +30,44 @@
# Copyright 2013 Hubspot
#
class nexus (
$version = $nexus::params::version,
$revision = $nexus::params::revision,
$deploy_pro = $nexus::params::deploy_pro,
$download_site = $nexus::params::download_site,
$download_proxy = undef,
$nexus_type = $nexus::params::type,
$nexus_root = $nexus::params::nexus_root,
$nexus_home_dir = $nexus::params::nexus_home_dir,
$nexus_work_dir = undef,
$nexus_work_dir_manage = $nexus::params::nexus_work_dir_manage,
$nexus_user = $nexus::params::nexus_user,
$nexus_group = $nexus::params::nexus_group,
$nexus_host = $nexus::params::nexus_host,
$nexus_port = $nexus::params::nexus_port,
$nexus_work_recurse = $nexus::params::nexus_work_recurse,
$nexus_context = $nexus::params::nexus_context,
$nexus_manage_user = $nexus::params::nexus_manage_user,
$nexus_data_folder = $nexus::params::nexus_data_folder,
$download_folder = $nexus::params::download_folder,
$manage_config = $nexus::params::manage_config,
$md5sum = $nexus::params::md5sum,
) inherits nexus::params {
Pattern[/\d+.\d+.\d+/] $version,
String[1] $revision,
Boolean $deploy_pro,
Stdlib::HTTPUrl $download_site,
Stdlib::HTTPUrl $pro_download_site,
Optional[Stdlib::HTTPUrl] $download_proxy,
Enum['unix', 'win64', 'mac', 'bundle'] $nexus_type,
Stdlib::Absolutepath $nexus_root,
String[1] $nexus_home_dir,
Optional[Stdlib::Absolutepath] $nexus_work_dir,
Boolean $nexus_work_dir_manage,
String[1] $nexus_user,
String[1] $nexus_group,
Stdlib::Host $nexus_host,
Stdlib::Port $nexus_port,
Boolean $nexus_work_recurse,
String[1] $nexus_context,
Boolean $nexus_manage_user,
Boolean $nexus_selinux_ignore_defaults,
Optional[Stdlib::Absolutepath] $nexus_data_folder,
Stdlib::Absolutepath $download_folder,
Boolean $manage_config,
) {
include stdlib

# Bail if $version is not set. Hopefully we can one day use 'latest'.
if ($version == 'latest') or ($version == undef) {
fail('Cannot set version nexus version to "latest" or leave undefined.')
}

if $nexus_work_dir != undef {
$real_nexus_work_dir = $nexus_work_dir
} else {
if $version !~ /\d.*/ or versioncmp($version, '3.1.0') >= 0 {
if versioncmp($version, '3.1.0') >= 0 {
$real_nexus_work_dir = "${nexus_root}/sonatype-work/nexus3"
} else {
$real_nexus_work_dir = "${nexus_root}/sonatype-work/nexus"
}
}

# Determine if Nexus Pro should be deployed instead of OSS
validate_bool($deploy_pro)
if ($deploy_pro) {
if ( $download_site != $nexus::params::download_site) {
# Use any download site that was passed in
$real_download_site = $download_site
} else {
# No download site was specifically defined, the default is
# incorrect for pro so switch to the correct one
$real_download_site = $nexus::params::pro_download_site
}
$real_download_site = $pro_download_site
} else {
# Deploy OSS version. The default download_site, or whatever is
# passed in is the correct location to download from
Expand Down Expand Up @@ -114,7 +102,6 @@
nexus_work_dir => $real_nexus_work_dir,
nexus_work_dir_manage => $nexus_work_dir_manage,
nexus_work_recurse => $nexus_work_recurse,
md5sum => $md5sum,
notify => Class['nexus::service']
}

Expand All @@ -135,7 +122,6 @@
class { 'nexus::service':
nexus_home => "${nexus_root}/${nexus_home_dir}",
nexus_user => $nexus_user,
version => $version,
}

anchor{ 'nexus::setup': } -> Class['nexus::package'] -> Class['nexus::config'] -> Class['nexus::Service'] -> anchor { 'nexus::done': }
Expand Down
33 changes: 15 additions & 18 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,23 @@
# Copyright 2013 Hubspot
#
class nexus::package (
$version = $::nexus::version,
$revision = $::nexus::revision,
$deploy_pro = $::nexus::deploy_pro,
$download_site = $::nexus::download_site,
$nexus_type = $::nexus::nexus_type,
$nexus_root = $::nexus::nexus_root,
$nexus_home_dir = $::nexus::nexus_home_dir,
$nexus_user = $::nexus::nexus_user,
$nexus_group = $::nexus::nexus_group,
$nexus_work_dir = $::nexus::nexus_work_dir,
$nexus_work_dir_manage = $::nexus::nexus_work_dir_manage,
$nexus_work_recurse = $::nexus::nexus_work_recurse,
$nexus_selinux_ignore_defaults = $::nexus::nexus_selinux_ignore_defaults,
$download_folder = $::nexus::download_folder,
$download_proxy = $::nexus::download_proxy,
$md5sum = $::nexus::md5sum,
Pattern[/\d+.\d+.\d+/] $version = $::nexus::version,
String[1] $revision = $::nexus::revision,
Boolean $deploy_pro = $::nexus::deploy_pro,
Stdlib::HTTPUrl $download_site = $::nexus::download_site,
Enum['unix', 'win64', 'mac', 'bundle'] $nexus_type = $::nexus::nexus_type,
Stdlib::Absolutepath $nexus_root = $::nexus::nexus_root,
String[1] $nexus_home_dir = $::nexus::nexus_home_dir,
String[1] $nexus_user = $::nexus::nexus_user,
String[1] $nexus_group = $::nexus::nexus_group,
Optional[Stdlib::Absolutepath] $nexus_work_dir = $::nexus::nexus_work_dir,
Boolean $nexus_work_dir_manage = $::nexus::nexus_work_dir_manage,
Boolean $nexus_work_recurse = $::nexus::nexus_work_recurse,
Boolean $nexus_selinux_ignore_defaults = $::nexus::nexus_selinux_ignore_defaults,
Stdlib::Absolutepath $download_folder = $::nexus::download_folder,
Optional[Stdlib::HTTPUrl] $download_proxy = $::nexus::download_proxy,
) {

$nexus_home = "${nexus_root}/${nexus_home_dir}"

$full_version = "${version}-${revision}"

if ($deploy_pro) {
Expand Down
45 changes: 0 additions & 45 deletions manifests/params.pp

This file was deleted.

7 changes: 3 additions & 4 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@
# Copyright 2013 Hubspot
#
class nexus::service (
$nexus_home,
$nexus_user = $::nexus::nexus_user,
$nexus_group = $::nexus::nexus_group,
$version = $::nexus::version,
Stdlib::Absolutepath $nexus_home,
String[1] $nexus_user = $::nexus::nexus_user,
String[1] $nexus_group = $::nexus::nexus_group,
) {
$nexus_script = "${nexus_home}/bin/nexus"

Expand Down
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pest-nexus",
"version": "1.9.1",
"version": "2.0.0",
"author": "Puppets Epic Show Theatre",
"summary": "Puppet module for Sonatype Nexus",
"license": "MIT",
Expand Down Expand Up @@ -52,7 +52,7 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 4.10.0 < 8.0.0"
"version_requirement": ">= 6.0.0 < 8.0.0"
}
],
"pdk-version": "2.2.0",
Expand Down
5 changes: 2 additions & 3 deletions spec/acceptance/checksum_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
class{ '::java': }
class{ '::nexus':
version => '2.8.0',
revision => '05',
md5sum => 'e1cece1ae5eb3a12f857e2368a3e9dbc',
version => '2.8.0',
revision => '05',
nexus_root => '/srv',
}
EOS
Expand Down
Loading

0 comments on commit 5a6b7c1

Please sign in to comment.