Git initial commit

This commit is contained in:
Lars Hahn 2023-09-17 10:56:08 +02:00
commit 65acb4bd65
10 changed files with 226 additions and 0 deletions

9
LICENSE Executable file
View File

@ -0,0 +1,9 @@
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

3
README.md Executable file
View File

@ -0,0 +1,3 @@
# cloud-nexus
Ansible role to provide Sonatype Nexus as artifact storage.

16
defaults/main.yml Executable file
View File

@ -0,0 +1,16 @@
---
cloud_apps: /opt
cloud_storage: /opt/storage
cloud_stage: prod
cloud_update: false
java_home: "{{ cloud_apps }}/java-jdk/java"
nexus_source: https://download.sonatype.com/nexus/3
nexus_version: 3.37.3-02
nexus_java_home: "{{ java_home }}"
nexus_data_location: "{{ cloud_storage }}/sonatype-nexus-data"
nexus_http_port: 8081
nexus_http_host: 0.0.0.0

6
handlers/main.yml Executable file
View File

@ -0,0 +1,6 @@
---
- name: restart nexus
systemd:
name: nexus
state: restarted

17
meta/main.yml Executable file
View File

@ -0,0 +1,17 @@
---
galaxy_info:
role_name: nexus
namespace: hahn-cloud
author: Lars Hahn
company: OpenDevChain
license: MIT
description: Role to setup Sonatype Nexus Repository 3.X
min_ansible_version: 2.7
platforms:
- name: Debian
versions:
- 11
galaxy_tags:
- nexus
dependencies:
- java

99
tasks/main.yml Executable file
View File

@ -0,0 +1,99 @@
---
- name: setup nexus group
group:
name: "{{ nexus_usr }}"
state: "present"
- name: setup nexus user
user:
name: "{{ nexus_usr }}"
group: "{{ nexus_grp }}"
groups:
- "{{ nexus_grp }}"
comment: Virtual Sonytype Nesus User
shell: /bin/bash
state: present
system: yes
- name: setup nexus directories
file:
state: directory
path: "{{ item }}"
owner: "{{ nexus_usr }}"
group: "{{ nexus_grp }}"
mode: 0750
loop:
- "{{ nexus_home }}"
- "{{ nesux_dir }}"
- name: download nexus
unarchive:
src: "{{ nexus_source }}/nexus-{{ nexus_version }}-unix.tar.gz"
dest: "{{ nesux_dir }}"
remote_src: yes
owner: "{{ nexus_usr }}"
group: "{{ nexus_grp }}"
mode: 0750
creates: "{{ nexus_inst }}"
register: nexus_install
- block:
- name: move nexus home appropriately
copy:
src: "{{ nesux_dir }}/sonatype-work/nexus3"
dest: "{{ nexus_home }}"
owner: "{{ nexus_usr }}"
group: "{{ nexus_grp }}"
mode: 0750
- name: remove old home directory
file:
path: "{{ nesux_dir }}/sonatype-work"
state: absent
when: nexus_install.changed
- name: link installed nexus homedir
file:
state: link
src: "{{ nexus_inst }}"
dest: "{{ nexus_link }}"
owner: "{{ nexus_usr }}"
group: "{{ nexus_grp }}"
- name: setup nexus config directory
file:
state: directory
path: "{{ nexus_home }}/nexus3/etc"
owner: "{{ nexus_usr }}"
group: "{{ nexus_grp }}"
mode: 0750
- name: setup nexus vmoptions
template:
src: opt/sonatype-nexus/nexus/bin/nexus.vmoptions.j2
dest: "{{nexus_inst }}/bin/nexus.vmoptions"
owner: "{{ nexus_usr }}"
group: "{{ nexus_grp }}"
mode: 0750
notify: restart nexus
- name: setup nexus properties
template:
src: opt/sonatype-nexus-data/nexus-config/nexus.properties.j2
dest: "{{ nexus_home }}/nexus3/etc/nexus.properties"
owner: "{{ nexus_usr }}"
group: "{{ nexus_grp }}"
mode: 0750
notify: restart nexus
- name: setup nexus systemd unit
template:
src: etc/systemd/system/nexus.service.j2
dest: /etc/systemd/system/nexus.service
notify: restart nexus
- name: enable nexus systemd unit
systemd:
name: nexus
enabled: yes
daemon_reload: yes
state: started

View File

@ -0,0 +1,16 @@
[Unit]
Description=nexus service
After=network.target
[Service]
Type=forking
LimitNOFILE=65536
Environment="JAVA_HOME={{ nexus_java_home }}"
ExecStart={{ nexus_link }}/bin/nexus start
ExecStop={{ nexus_link }}/bin/nexus stop
User={{ nexus_usr }}
Restart=on-abort
TimeoutSec=600
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,12 @@
# Jetty section
application-port={{ nexus_http_port }}
application-host={{ nexus_http_host }}
# nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/
# Nexus section
# nexus-edition=nexus-pro-edition
# nexus-features=\
# nexus-pro-feature
# nexus.hazelcast.discovery.isEnabled=true

View File

@ -0,0 +1,40 @@
-Xms{{ nexus_javaheap_min | default('2703m') }}
-Xmx{{ nexus_javaheap_max | default('2703m') }}
-XX:MaxDirectMemorySize={{ nexus_javaheap_directmax | default('2703m') }}
-XX:+UnlockDiagnosticVMOptions
-XX:+LogVMOutput
-XX:LogFile={{ nexus_home }}/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data={{ nexus_home }}/nexus3
-Dkaraf.log={{ nexus_home }}/nexus3/log
-Djava.io.tmpdir={{ nexus_home }}/nexus3/tmp
-Dkaraf.startLocalConsole=false
-Djdk.tls.ephemeralDHKeySize=2048
#
# additional vmoptions needed for Java9+
#
# --add-reads=java.xml=java.logging
# --add-exports=java.base/org.apache.karaf.specs.locator=java.xml,ALL-UNNAMED
# --patch-module java.base=${KARAF_HOME}/lib/endorsed/org.apache.karaf.specs.locator-4.3.2.jar
# --patch-module java.xml=${KARAF_HOME}/lib/endorsed/org.apache.karaf.specs.java.xml-4.3.2.jar
# --add-opens java.base/java.security=ALL-UNNAMED
# --add-opens java.base/java.net=ALL-UNNAMED
# --add-opens java.base/java.lang=ALL-UNNAMED
# --add-opens java.base/java.util=ALL-UNNAMED
# --add-opens java.naming/javax.naming.spi=ALL-UNNAMED
# --add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED
# --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED
# --add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED
# --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED
# --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED
# --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED
# --add-exports java.security.sasl/com.sun.security.sasl=ALL-UNNAMED
#
# comment out this vmoption when using Java9+
#
-Djava.endorsed.dirs=lib/endorsed

8
vars/main.yml Executable file
View File

@ -0,0 +1,8 @@
---
nexus_usr: sonanexus
nexus_grp: "{{ nexus_usr }}"
nesux_dir: "{{ cloud_apps }}/sonatype-nexus"
nexus_inst: "{{ nesux_dir }}/nexus-{{ nexus_version }}"
nexus_home: "{{ nexus_data_location }}"
nexus_link: "{{ nesux_dir }}/nexus"