Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 30 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,87 @@
# Nexus OSS Repository Saltstack Formula
This Saltstack formula will install Nexus OSS Repository onto any linux (tested with debian jessie, CentOS 5,6,7).
This Saltstack formula will install Nexus OSS Repository onto any Linux (tested with Debian Jessie, CentOS 5, 6, 7).

**Requires Nexus Sonatype Version 3 and above.**

# Use
In your formula matching sls just add
In your formula matching, SLS just add
```nexus```

# ToDos
- Make certificates importable, official CA etc.
- Make java keystore replaceable if changes in the pillar occur. delete old one etc.
- Make certificates importable, official CA, etc.
- Make java keystore replaceable if changes in the pillar occur. Delete old one etc.
- Obscure password in jetty-https.xml
- Make this formula updateable
- Set the symlink to the new version
- Do not touch the sonatype-work folder
- Copylivedata
- Problem that after running the copyjob, another salt-call has to be done, so that the configuration files will be created correctly.
- The problem that after running the copy job, another salt-call has to be done, so that the configuration files will be created correctly.

# Guide
Questions regarding "how to configure nexus" take a look at the sonatype documentation website. http://books.sonatype.com/nexus-book/reference3/index.html
Questions regarding "how to configure nexus" take a look at the Sonatype documentation website. http://books.sonatype.com/nexus-book/reference3/index.html

## Prerequisites
1.) Requires Java JRE

2.) Knowledge in Nexus OSS

## States
The default state is `nexus` this one will install, configure and creates a systemd entry for nexus.
There is also `nexus.v3.copylivedata` which will copy data from another host, to this local system.
The default state is `nexus` this one will install, configure and creates a systemd entry for the nexus.
There is also `nexus.v3.copylivedata` which will copy data from another host to this local system.

### nexus.v3.copylivedata
Needs an existing ssh key on the host system.

## Defaults
1.) HTTPS will be configured and a self signed certificate is going to be created if `applicationportssl` is uncommented.
1.) HTTPS will be configured, and a self-signed certificate is going to be created if `applicationportssl` is uncommented.

2.) The passwords for the java keystore is **neither encrypted nor obscured** in the `jetty-https.xml`.
2.) The passwords for the Java keystore is **neither encrypted nor obscured** in the `jetty-https.xml`.

## Recommendations
1.) Run Nexus OSS behind a reverseproxy. No issues with the self signed certificate will occur.
1.) Run Nexus OSS behind a reverse proxy. No issues with the self-signed certificate will occur.

### Variables
Every variable is setable. If nothing is specified in the pillar it will be set via the `defaults.yaml`.
Every variable is settable. If nothing is specified in the pillar, it will be set via the `defaults.yaml`.

## Pillar Data
Use the pillar.example, every variable is commented.

## File Structure
Nexus OSS can be installed anywhere on linux. Per default it will be installed onto `/opt` the following directories will be created
Nexus OSS can be installed anywhere on Linux. Per default it will be installed onto `/opt` the following directories will be created

`nexus` is a symlink pointing to the installed version.

`nexus-versionnumber` is created while extracting, can be set via `install.path` in pillar
`nexus-versionnumber` is created while extracting, can be set via `install.path` in the pillar

`sonatype-work` is created while extracting, can be set via `install.datapath` in pillar symlink in `install.path` will be created

### Configurationfiles
The following file will be created and modified via salt

`jetty-https.xml` used for https activation, stores the password to the java keystore
`jetty-https.xml` used for https activation, stores the password to the Java keystore

`nexus.properties` used for https activation, autoredirects, ssl and non ssl ports, and many more
`nexus.properties` used for https activation, auto-redirects, SSL and non-SSL ports, and many more

`nexus.rc` used to run nexus as the specified user

`nexus.service` creates a systemctl entry, runs nexus as the specified user

`nexus.vmoptions` used to edit java vm preferences

# Plugins
A plugins can be loaded if they are specified in the pillar under `nexus.plugins`.

```
For now, only support for nexus-repository-apt is done, feel free to use it as a template for other ones.
Be aware of plugin version compatibility with your installed version!
```
nexus-repository-apt:
Compile plugin it as it is mentioned [here](https://github.com/sonatype-nexus-community/nexus-repository-apt)
Point your pillar `nexus.plugins.nexus_repository_apt.path` to it.




# Version 2

Formula to set up and configure a Sonatype Nexus server.
Expand Down
12 changes: 7 additions & 5 deletions nexus/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

{% from "nexus/map.jinja" import nexus with context %}

#using v3
{% if nexus.download.version is defined %}
include:

{% set major_version = nexus.download.version %}

#using v3
{% if major_version[0] == '3' %}
- nexus.v3.init
{% endif %}

#using v2
{% if nexus.version is defined %}
include:
{% if major_version[0] == '2' %}
- nexus.v2.init
{% endif %}
{% endif %}
8 changes: 7 additions & 1 deletion nexus/v3/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ include:
- nexus.v3.install
- nexus.v3.config
- nexus.v3.service

{%- if pillar.nexus.plugins is defined %}

{%- if pillar.nexus.plugins.nexus_repository_apt is defined %}
- nexus.v3.plugins.nexus-repository-apt
{% endif %}

{% endif %}
44 changes: 44 additions & 0 deletions nexus/v3/plugins/nexus-repository-apt.sls
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
# GitHub: https://github.com/sonatype-nexus-community/nexus-repository-apt
# Sonatype Documentation: http://exchange.sonatype.com/details?extension=4719699238

{% from "nexus/map.jinja" import nexus with context %}

{% set nexus_core_features_xml = nexus.install.path + "/nexus/system/org/sonatype/nexus/assemblies/nexus-core-feature/" + nexus.download.version + "/nexus-core-feature-" + nexus.download.version + "-features.xml" %}

{% set commons_compress_version = salt["cmd.shell"]("grep -m 1 commons-compress " + nexus_core_features_xml + " | sed -e 's/.*commons-compress\/\(.*\)<\/b.*/\\1/'" ) %}

Download the plugin:
file.managed:
- name: {{ nexus.install.path }}/nexus/system/net/staticsnow/nexus-repository-apt/{{ nexus.plugins.nexus_repository_apt.version }}/nexus-repository-apt-{{ nexus.plugins.nexus_repository_apt.version }}.jar
- source: {{ nexus.plugins.nexus_repository_apt.path }}
- keep: True
- user: {{ nexus.user.name }}
- group: {{ nexus.user.group }}
- mode: 644
- dir_mode: 755
- makedirs: True
- follow_symlinks: true
- replace: False

Add specification to nexus-core-feature:
file.line:
- name: {{ nexus_core_features_xml }}
- content: <feature prerequisite="false" dependency="false">nexus-repository-apt</feature>
- mode: ensure
- after: <feature version="{{ nexus.download.version | replace('-','.') }}" prerequisite="false" dependency="false">nexus-repository-maven</feature>
- indent: True

Add specification to nexus-core-features list:
file.line:
- name: {{ nexus_core_features_xml }}
- content: '
<feature name="nexus-repository-apt" description="net.staticsnow:nexus-repository-apt" version="{{ nexus.plugins.nexus_repository_apt.version }}">
<details>net.staticsnow:nexus-repository-apt</details>
<bundle>mvn:net.staticsnow/nexus-repository-apt/{{ nexus.plugins.nexus_repository_apt.version }}</bundle>
<bundle>mvn:org.apache.commons/commons-compress/{{ commons_compress_version }}</bundle>
</feature>'
- mode: ensure
- before: <\/features>
- indent: True
5 changes: 5 additions & 0 deletions pillar-v3.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ nexus:
path: '/opt'
# add the datapath /opt/sonatype-work no trailing /
datapath: '/srv/sonatype-work'
plugins:
nexus_repository_apt:
# The plugin's path to download to the minion, this can be hosted on either the salt master server (salt://), the salt minion local file system (/), or on an HTTP or FTP server (http(s)://, ftp://)
path: '/tmp/nexus-repository-apt-1.0.5.jar'
version:'1.0.5'
user:
# generate a system user with the name 'nexus'
name: 'nexus'
Expand Down