Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

nexus3 (36) Versions 3.4.1

Installs/Configures Sonatype Nexus 3 Repository Manager

Policyfile
Berkshelf
Knife
cookbook 'nexus3', '= 3.4.1', :supermarket
cookbook 'nexus3', '= 3.4.1'
knife supermarket install nexus3
knife supermarket download nexus3
README
Dependencies
Changelog
Quality 83%

Nexus3 Cookbook

Cookbook Version
Build Status

This cookbook installs and configures Sonatype Nexus 3 Repository
Manager OSS according to
https://books.sonatype.com/nexus-book/reference3/install.html

Usage

Use the nexus3 resource
to download and install the latest Nexus 3 Repository Manager OSS.

Use the nexus3_api
resource to configure Nexus 3 Repository Manager via its REST API.

Use the nexus3_repo
resource to configure Nexus 3 repositories.

Use the nexus3_group
resource to configure Nexus 3 repository groups.

Use the nexus3_user
resource to configure Nexus 3 users.

Use the nexus3_realm
resource to handle realm activation.

Requirements

  • Chef 12.14.34+
  • ark cookbook
    • Note: include_recipe 'ark' is required for Windows servers, as it is not implicit.
  • Java 8+ from Oracle or OpenJDK (not installed, pick your own)

Platforms

  • CentOS, RedHat, Fedora
  • Debian, Ubuntu
  • Windows

Recipes

default

Downloads and installs the latest Nexus 3 Repository Manager OSS.

Attributes

  • node['nexus3']['version'] - The version of Nexus 3 to download. Default 3.2.1-01.
  • node['nexus3']['url'] - The download URL of Nexus 3 Repository Manager. This can be a specific version of Nexus Repository Manager OSS or Nexus Repository Manager Pro. Default http://download.sonatype.com/nexus/3/nexus-3.2.1-01-unix.tar.gz.
  • node['nexus3']['checksum'] (optional) - The checksum of Nexus Repository Manager. Default nil.
  • node['nexus3']['path'] - Install directory. Default Linux: /opt Windows: #{ENV['SYSTEMDRIVE']}.
  • node['nexus3']['data'] - Data directory. Default #{node['nexus3']['path']}/sonatype-work/nexus3.
  • node['nexus3']['home'] - Link to install directory. Default #{node['nexus3']['path']}/nexus3.
  • node['nexus3']['properties_variables'] - A Hash of variables that are passed into a template file. Default { host: '0.0.0.0', port: '8081', args: '${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml', context_path: '/' }.
  • node['nexus3']['vmoptions_variables'] - A Hash of variables that are passed into a template file. Note that data directory will be injected into the hash if it is not defined. Default { Xms: '1200M', Xmx: '1200M' }.
  • node['nexus3']['nofile_limit'] - Limit of open files available for the Nexus3 service in systemd. Default 65,536 as suggested by the Sonatype documentation on newer releases.

Examples

Changing the HTTP Port and/or Context Path

The default value for the HTTP port used to access the repository manager user interface and resources is 8081.
To change HTTP Port to 8443, Context Path to /components/ and serve HTTPS directly set the properties_variables hash with the updated settings:

include_recipe 'java_se'

node.default['nexus3']['properties_variables'] = { port: '8443', args: '${jetty.etc}/jetty.xml,${jetty.etc}/jetty-https.xml,${jetty.etc}/jetty-requestlog.xml', context_path: '/components/' }
include_recipe 'nexus3'

Updating Memory Allocation and other JVM Paramaters

The default and maximum heap sizes for the repository manager are a value of
1200 MB, suitable for most usage patterns. To install latest nexus3 with 1500 MB
initial memory and 2 GB max memory, set it in the vmoptions_variables:

include_recipe 'java_se'

node.default['nexus3']['vmoptions_variables'] = { Xms1500M: nil, Xmx2G: nil }
include_recipe 'nexus3'

The vmoptions_variables attributes are mapped to JVM options -<key>=<value> if a value
is defined. If <value> is nil, the option becomes -<key>.

Resources

Properties common to all resources using the Nexus3 API

api_client - A ::Nexus3::Api instance. Default is configured using
following nexus3.api attributes: endpoint, username & password

nexus3

Downloads and installs the latest Nexus Repository Manager OSS v3.

Actions

  • :install - Default. Downloads and installs the latest Nexus Repository Manager OSS v3.

Since the installation is resource-based, you can install different Nexus3
instances on the same node. Make sure to specify different home and data
directories, as well as different port numbers.

Attributes

  • instance_name - Name of service. Default value is the name of the resource block.
  • nexus3_user - The owner of nexus3. Creates a nexus user with the value passed in. Default node['nexus3']['user'].
  • nexus3_group - The group of nexus3. Creates a nexus group with the value passed in. Default node['nexus3']['group'].
  • version - Version of Nexus3 to install. Default node['nexus3']['version']
  • url - The download URL of latest Nexus 3 Repository Manager OSS. This can be updated to download a specific version of Nexus Repository Manager OSS or Nexus Repository Manager Pro. Default node['nexus3']['url'].
  • checksum (optional) - The checksum of Nexus Repository Manager. Default node['nexus3']['checksum'].
  • data - Data directory. Default node['nexus3']['data'].
  • path - Install directory. Default node['nexus3']['path'].
  • nexus3_home - Link to install directory. Default node['nexus3']['home'].
  • service_name - Name of service used for the system service manager (systemd or other). Defaults to instance_name.
  • properties_variables - A Hash of variables that are passed into a template file. Default node['nexus3']['properties_variables'].
  • vmoptions_variables - A Hash of variables that are passed into a template file. Note that data directory will be injected into the hash if it is not defined. Default node['nexus3']['vmoptions_variables'].

Examples

Changing the HTTP Port and/or Context Path and/or HTTP vs HTTPS

The default value for the HTTP port used to access the repository manager user interface and resources is 8081.
To change HTTP Port to 8443, Context Path to /components/ and serve HTTPS directly, set the properties_variables hash with the updated settings:

include_recipe 'java_se'

nexus3 'nexus' do
  properties_variables(
    host: '0.0.0.0',
    port: '8443',
    args: '${jetty.etc}/jetty.xml,${jetty.etc}/jetty-https.xml,${jetty.etc}/jetty-requestlog.xml',
    context_path: '/components/'
  )
  action :install
end

Updating Memory Allocation and other JVM Paramaters

The default and maximum heap sizes for the repository manager are a value of 1200M, suitable for most usage patterns.
To install latest nexus3 with 1500M initial memory and 2G max memory, set it in the vmoptions_variable:

include_recipe 'java_se'

nexus3 'nexus' do
  vmoptions_variables(
    Xms: '1500M',
    Xmx: '2G'
  )
  action :install
end

nexus3_api

Configures Nexus 3 Repository Manager via API. Low-level resource, usually
used within other resources.

Actions

  • :create - Creates or updates the named script on the repository manager (default action).
  • :run - Runs the named script on the repository manager. The script must already have been created.
  • :delete - Deletes the named script from the repository manager.

Properties

  • script_name - Name of script. Default value is the name of the resource block.
  • content - Content of script. This is usually Groovy, see Sonatype Nexus 3 documentation for more information, or see the example scripts in the repo resource.
  • args - Hash, String or NilClass arguments passed when :run is called.

Examples

See api_examples for more examples of using
nexus3_api resource to configure Nexus Repository Manager. Pull Requests improving or adding additional
API Examples are welcome and encouraged.

Simple repository creation script

Creates or updates private script on Nexus 3 Repository Manager, then runs the script.

nexus3_api 'private' do
  content "repository.createMavenHosted('private')"
  action :run
end

nexus3_repo

Configures Nexus 3 repositories via API. This works by calling a Groovy script
which will trigger the creation, update or deletion of a given repository. For
ease of reading the source code, scripts are stored under files/default with
the help of libraries/scripts_helper.rb.

Actions

  • :create - Creates or updates a repository, passing a configuration via args.
  • :delete - Deletes a repository.

Properties

  • repo_name - Name of repository to act on, defaults to resource property name.
  • repo_type - Type (or recipe in Nexus 3 words) of repository to create, among maven2-hosted, maven2-proxy, 'npm-hosted`, ... (default: 'maven2-hosted')
  • attributes - Hash of attributes passed to the :create action, used to specify repository attributes for creation or update.
  • online - Whether to put the repository online or not (default: true).

nexus3_task

Configures scheduled tasks via API.

Actions

  • :create - Creates or updates a scheduled task.
  • :delete - Removes a scheduled task.

Properties

  • task_name - Name of task to act on, defaults to resource name.
  • task_source - Source code of the script to run, for now it defaults to running Groovy scripts (typeID: script).
  • task_crontab - Actual schedule in the form of a crontab string.

nexus3_realm

Handle realm activation via API.

Actions

  • :configure - Configure a given realm.

Properties

  • realm_name - Name of realm to act on, defaults to resource name.
  • enable - Whether to enable a given realm.

nexus3_group

Configures Nexus 3 repository groups via API. This works wrapping the nexus3_repo
resource with names of member repositories added as an attribute.

Actions

  • :create - Creates or updates a group, passing a configuration via attributes.
  • :delete - Deletes a group.

Properties

  • group_name - Name of repository group to act on, defaults to resource property name.
  • group_type - Type (or recipe in Nexus 3 words) of repository group to create, among maven2-group, 'npm-group`, ... (default: 'maven2-group')
  • attributes - Hash of attributes passed to the :create action, used to specify repository attributes for creation or update.
  • online - Whether to put the repository online or not (default: true).
  • repositories - Array of repository names that compose the group.

nexus3_user

Configures users for use with Nexus3. Users can be assigned roles and
privileges, which are seen in the nexus3_role resource.

Actions

  • :create - Creates or updates a user. You can change a non-admin user's password with this resource. You will have to use a (yet to be written) nexus3_admin_password resource to update the current admin password.
  • :delete - Deletes a user.

Properties

  • username - Username to create, defaults to resource name.
  • password - Password of user.
  • first_name - User first name.
  • last_name - User last name.
  • email - User email address.
  • roles - Array of roles to assign to the user (either the default ones or those added with the nexus3_role resource).

nexus3_role

Configures roles to use with Nexus3, so you can assign users to these roles
later. Roles are associated with a list of privileges defined by Nexus3 and
can be nested.

Actions

  • :create - Creates or updates a role.
  • :delete - Deletes a role.

Properties

  • role_name - Name of role to update, defaults to resource name.
  • description - A free-form description of the role.
  • roles - Array of roles that are part of this role. If any role does not exist, it will be ignored if you use the script provided.
  • privileges - Array of privileges defined in Nexus3.

nexus3_cleanup_policy

Configures Cleanup Policy to use with Nexus3 repositories, so you can configure
rentention limit. Policies are per repository format and relative to either the
artifact's publish_date or its last download date.

Actions

  • :create - Creates or updates a policy.
  • :delete - Deletes a policy.

Properties

  • policy_name - Name of the policy to manage, defaults to resource name.
  • notes - A small description about the cleanup policy.
  • format - The target repository format, defaults to 'raw'.
  • mode - Cleanup mode, currently only 'delete' seems to be supported.
  • criteria - Hash of rules to control the cleanup.

Criteria rules

Supported criteria may vary depending on the repository format, but the 2 main ones are:
- lastBlobUpdated - Cleanup artifacts published more than the given number of seconds ago.
- lastDownloaded - Cleanup artifacts last downloaded more than the given number of seconds ago.

NB: criteria is the number of seconds as String.

Example

nexus3_cleanup_policy 'example' do
  format 'raw'
  notes  'Cleanup all artifacts uploaded more 7 days ago AND last downloaded more than 3 days ago.'
  criteria lastBlobUpdated: '604800', lastDownloaded: '259200'
end

Getting Help

Contributing

Please refer to CONTRIBUTING.

License and Authors

Authors: Denis Hoer (dennis.hoer@gmail.com)

License: MIT - see the accompanying LICENSE file for details.

Dependent cookbooks

ark >= 0.0.0
updatable-attributes >= 0.0.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

Changelog

3.4.1 2019-10-29

  • Support Multi-policy Cleanup on repo creation

3.4.0 2019-10-18

  • Pin faraday to version compatible with this cookbook
  • Bump to latest version 3.19.1
  • Update tests to change admin password as it is not the default anymore, it is generated randomly at installation.

3.3.0 2019-06-26

  • Fix a bug where last option in vmoptions would be ignored

3.2.0 2019-06-13

  • Make scripts helper usable by other cookbooks.
    • This lets you easily register scripts which reside in your own cookbooks.
  • Bump nexus3 version to 3.16.2

3.1.0 2019-04-03

A lot of changes went into this release.

  • Capture Errno::EHOSTUNREACH exception.
    • It was raising an exception rather than retrying on first converge.
  • Stop depending on an outdated Java installation for tests.
  • Be more precise in setting the JVM options.
  • Extend nexus.properties with application-port-ssl.
  • Bump nexus3 version to 3.15.2.
  • Add nexus3_cleanup_policy resource.
    • This lets you define new cleanup polices for your repositories.
  • Add nexus3_realm resource.
    • This lets you handle activation on secutiry realm.

3.0.0 2018-06-15

A lot of changes went into this release.

  • Made Nexus3 installation a resource to support multi-tenancy.
    • SysVinit or Systemd Linux systems are supported, as well as Windows.
    • JVM settings are attribute-driven.
  • Users, groups, repositories, roles and tasks can now be created via resources.
    • All these functions are supported by Groovy scripts uploaded to the Nexus3 via its REST API.
  • An API resource does most of the job of talking to Nexus3 for all operations.
  • All operations are idempotent and will wait on Nexus3 startup.
  • A comprehensive test suite is included (ChefSpec and Kitchen/ServerSpec)
  • Criteo took over maintenance of the cookbook (Thank you Dennis for your hard work supporting the cookbook previously!)

2.1.0 2017-03-14

  • Add another variable to nexus.properties.erb to configure nexus-args

2.0.1 2017-03-08

  • Update uninstall so it doesn't delete the entire contents of /opt

2.0.0 2016-12-17

  • Refactor for 3.1

1.0.0 2016-11-14

  • Fix #17 nexus 3.1.0 config file location changed

0.9.2 2016-10-14

  • Fix #16 Fixes version regex that matches host-name when containing digits

0.9.1 2016-09-06

  • Fix #13 Wrong home folder

0.9.0 2016-09-05

  • Make application-host configurable

0.8.0 2016-08-20

  • Fix #11 Do not set user home to path dir

0.7.0 2016-08-19

  • Replace root attribute with path
  • Fix #10 nexus3_api ignore_failure attribute defaults to false

0.6.0 2016-08-15

  • Fix #9 Why_run/converge_by causes notifies to fire when no changes

0.5.0 2016-08-13

  • Resolve #5 Add support for Windows configuration

0.4.0 2016-08-11

  • Wait for Nexus Rest API endpoint to respond
  • Replace vmoptions attribute with template

0.3.0 2016-08-08

  • Fix #4 Support Windows install
  • Fix #6 Change install directory to closely match docker image

0.2.1 2016-08-01

  • Fix #2 Custom url issue

0.2.0 2016-07-29

  • Add REST API

0.1.1 2016-07-28

  • Fix #1 FileNotFoundException due to Chef searching for template files in a wrapper cookbook

0.1.0 2016-07-26

  • Initial beta release

Collaborator Number Metric
            

3.4.1 passed this metric

Contributing File Metric
            

3.4.1 passed this metric

Foodcritic Metric
            

3.4.1 passed this metric

No Binaries Metric
            

3.4.1 passed this metric

Testing File Metric
            

3.4.1 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

3.4.1 passed this metric