From a8251e0a9b9eb13c6eace88f6d3b24cf9ffaaf83 Mon Sep 17 00:00:00 2001 From: Angelo Verona Date: Mon, 7 May 2018 16:29:35 +0200 Subject: [PATCH] - Added option to install nexus-repository-apt plugin - Fixed some types, there and there - Adjusted version recognition as previous one was confusing as both could be defined at once --- README.md | 46 +++++++++++++++-------- nexus/init.sls | 12 +++--- nexus/v3/init.sls | 8 +++- nexus/v3/plugins/nexus-repository-apt.sls | 44 ++++++++++++++++++++++ pillar-v3.example | 5 +++ 5 files changed, 93 insertions(+), 22 deletions(-) create mode 100644 nexus/v3/plugins/nexus-repository-apt.sls diff --git a/README.md b/README.md index af40992..f9b0ea8 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,24 @@ # 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 @@ -26,41 +26,41 @@ Questions regarding "how to configure nexus" take a look at the sonatype documen 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 @@ -68,6 +68,20 @@ The following file will be created and modified via salt `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. diff --git a/nexus/init.sls b/nexus/init.sls index 13aa08b..bfc2479 100644 --- a/nexus/init.sls +++ b/nexus/init.sls @@ -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 %} \ No newline at end of file +{% endif %} diff --git a/nexus/v3/init.sls b/nexus/v3/init.sls index cbf9fa5..dd0d2de 100644 --- a/nexus/v3/init.sls +++ b/nexus/v3/init.sls @@ -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 %} diff --git a/nexus/v3/plugins/nexus-repository-apt.sls b/nexus/v3/plugins/nexus-repository-apt.sls new file mode 100644 index 0000000..cb6327c --- /dev/null +++ b/nexus/v3/plugins/nexus-repository-apt.sls @@ -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: nexus-repository-apt + - mode: ensure + - after: nexus-repository-maven + - indent: True + +Add specification to nexus-core-features list: + file.line: + - name: {{ nexus_core_features_xml }} + - content: ' + +
net.staticsnow:nexus-repository-apt
+ mvn:net.staticsnow/nexus-repository-apt/{{ nexus.plugins.nexus_repository_apt.version }} + mvn:org.apache.commons/commons-compress/{{ commons_compress_version }} +
' + - mode: ensure + - before: <\/features> + - indent: True diff --git a/pillar-v3.example b/pillar-v3.example index 834331d..6f53ad3 100644 --- a/pillar-v3.example +++ b/pillar-v3.example @@ -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'