Forge Home

nexus

Puppet module for Sonatype Nexus Repository Manager 3

5,394 downloads

527 latest version

5.0 quality score

Version information

  • 3.3.0 (latest)
  • 3.2.0
  • 3.1.0
  • 3.0.0
  • 2.0.0
  • 1.9.2
  • 1.9.1
  • 1.9.0
  • 1.8.0
  • 1.7.5
  • 1.7.4
released Mar 15th 2022
This version is compatible with:
  • Puppet Enterprise 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x
  • Puppet >= 6.0.0 < 8.0.0
  • , , ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'pest-nexus', '3.3.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add pest-nexus
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install pest-nexus --version 3.3.0

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

pest/nexus — version 3.3.0 Mar 15th 2022

Sonatype Nexus Repository Manager 3 Puppet module

Install and configure Sonatype Nexus Repository Manager 3.

This module was forked from hubspot/nexus.

Requirements of this module

  • puppet/archive
  • puppet/extlib
  • puppetlabs/stdlib

Migration from pre 3.x versions of this module

With version 3.0.0 we changed the default installation path from /srv to /opt/sonatype.

To migrate your current installation you will have to put something like the following into your role_nexus_server.pp:

  # shutdown the currently running service as we have to modify the operation system user
  exec { 'shutdown-running-service':
    command => '/usr/bin/systemctl stop nexus.service',
    onlyif  => [
      '/usr/bin/test -d /srv/sonatype-work',
      '/usr/bin/test ! -d /opt/sonatype/sonatype-work'
    ],
    before  => [
      Class['nexus::package'],
      Class['nexus::user']
    ],
  }

  # nexus::package will extract the archive which contains an empty work directory
  exec { 'remove-empty-work-directory':
    command => '/usr/bin/rm -rf /opt/sonatype/sonatype-work',
    onlyif  => [
      '/usr/bin/test -d /srv/sonatype-work',
      '/usr/bin/test -d /opt/sonatype/sonatype-work'
    ],
    before  => [
      Exec['move-work-directory-to-new-location']
    ],
    require => [
      Class['nexus::package'],
    ]
  }

  # move the old working directory to the new location
  exec { 'move-work-directory-to-new-location':
    command => '/usr/bin/mv /srv/sonatype-work /opt/sonatype/',
    onlyif  => [
      '/usr/bin/test -d /srv/sonatype-work',
      '/usr/bin/test ! -d /opt/sonatype/sonatype-work'
    ],
    require => [
      Class['nexus::package'],
      Exec['remove-empty-work-directory'],
    ],
    before  => Class['nexus::service'],
  }

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 download link and determining the name of the nexus directory.

class role_nexus_server {
  
  # puppetlabs-java
  # NOTE: Nexus requires
  class{ 'java': }
  
  class{ 'nexus':
    version               => '3.37.3',
    revision              => '02',
    nexus_type            => 'unix',
  }
  
  Class['java'] ->
  Class['nexus']

}

Valid versions and revisions can be picked from the official page

Nginx proxy

The following is setup for using the puppet/puppet-nginx module. Nexus does not adequately support HTTP and HTTPS simultaneously. Below forces all connections to HTTPS. Be sure to login after the app is up and head to Administration -> Server. Change the base URL to "https" and check "Force Base URL". The application will be available at:

https://${::fqdn}/

  class{ '::nginx': }

  file { '/etc/nginx/conf.d/default.conf':
    ensure => absent,
    require => Class['::nginx::package'],
    notify => Class['::nginx::service']
  }

  nginx::resource::vhost { 'nexus':
    ensure            => present,
    www_root          => '/usr/share/nginx/html',
    rewrite_to_https  => true,
    ssl               => true,
    ssl_cert          => '/etc/pki/tls/certs/server.crt',
    ssl_key           => '/etc/pki/tls/private/server.key',
  }

  nginx::resource::location { 'nexus':
    ensure    => present,
    location  => '/',
    vhost     => 'nexus',
    proxy     => "http://${nexus::host}:${nexus::port}",
    ssl       => true,
  }

Docker

To use nexus repository for docker you need to read the documentation for some additional config settings. Docker Repository Reverse Proxy Strategies

  nginx::resource::location { 'nexus':
    ensure    => present,
    location  => '/',
    locations => {
      'docker-v2' => {
        location => '/v2/',
        proxy    => "http://${nexus::host}:${nexus::port}/repository/docker-hosted/v2/",
      }
    },
    vhost     => 'nexus',
    proxy     => "http://${nexus::host}:${nexus::port}",
    ssl       => true,
  }

Keep in mind that pushing to docker group repository is a pro feature of nexus repository manager.

TODO

  • Find a way to not require a version to be passed to Class['nexus']

Authors

Copyright

Hubspot, Inc.