Forge Home

nexus

Puppet module for Sonatype Nexus Repository Manager 3

9,924 downloads

148 latest version

5.0 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 4.1.0 (latest)
  • 4.0.0
  • 3.5.0
  • 3.4.0
  • 3.3.0
  • 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 Aug 16th 2024
This version is compatible with:
  • Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x
  • Puppet >= 7.0.0 < 9.0.0
  • , , ,

Start using this module

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

Add this module to your Puppetfile:

mod 'pest-nexus', '4.1.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 4.1.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 4.1.0 Aug 16th 2024

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.42.0-01',
  }
  
  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.