Skip to content

Commit

Permalink
working version
Browse files Browse the repository at this point in the history
  • Loading branch information
Jochen Hinrichsen committed Nov 17, 2014
1 parent c7cfece commit 8cc3355
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 3 deletions.
48 changes: 45 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,46 @@
ansible-nexus
=============
Role Name
=========

Ansible playbook to install Sonatype Nexus (free edition)
Ansible Sonatype Nexus role. Completely independent from any package manager.
Does not require root or sudo permission to run.

TODO
----
- Add datadir (plus entry nexus-work={{datadir}} in conf/nexus.properties
- Change default admin account (admin/admin123)



Role Variables
--------------

- **nexus_download_dir**: download path on the control machine that will be used. Defaults to *'/tmp'*
- **nexus_version**: Nexus version to be installed. Defaults to *'latest'*
- **nexus_installation_dir**: installation prefix that will be used on installation hosts. Defaults to *'/usr/share'*
- **nexus_work_dir**: working directory, aka sonatype-work
- **nexus_port**: TCP port

Dependencies
------------

wget (on host, not on clients)

Example Playbook
----------------

Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:

- hosts: servers
roles:
- { role: jhinrichsen.nexus, nexus_installation_dir: '/opt' }

License
-------

MIT

Author Information
------------------

This playbook is heavily inspired by Alexander Ramos Jardim.
Any errors are probably my fault.
10 changes: 10 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# defaults file for ansible-nexus
nexus_download_dir: '/tmp'
# nexus_package: 'nexus-2.10.0-02-bundle.tar.gz'
nexus_package: 'nexus-latest-bundle.tar.gz'
nexus_version: 'latest'
nexus_installation_dir: '/usr/share'
nexus_working_dir: '/var/nexus'
nexus_port: 9999

2 changes: 2 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# handlers file for ansible-nexus
14 changes: 14 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
galaxy_info:
author: Jochen Hinrichsen
description: Sonatype Nexus playbook
license: MIT
min_ansible_version: 1.6
platforms:
- name: GenericLinux
versions:
- all
- any
categories:
- system
dependencies: []
7 changes: 7 additions & 0 deletions playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---

- hosts: dev
roles:
- { role: jhinrichsen.nexus,
nexus_version: '2.10.0-02',
sudo: yes}
1 change: 1 addition & 0 deletions roles/jhinrichsen.nexus
42 changes: 42 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# tasks file for ansible-nexus
- name: download Nexus to host
local_action: >
command wget -N -P "{{nexus_download_dir}}" http://download.sonatype.com/nexus/oss/{{nexus_package}}
tags: download
sudo: no

- name: "{{nexus_installation_dir}} must exist"
file:
path="{{nexus_installation_dir}}"
state="directory"

- name: Unpacks Nexus download
unarchive:
src="{{nexus_download_dir}}/{{nexus_package}}"
dest="{{nexus_installation_dir}}"
creates="{{nexus_installation_dir}}/nexus-{{nexus_version}}/bin/nexus"
force=no
tags: unpack

- name: Move sonatype working directory into place (1/2)
stat: path="{{nexus_installation_dir}}/sonatype-work"
register: s_w

- name: Move sonatype working directory into place (2/2)
command: mv "{{nexus_installation_dir}}/sonatype-work" "{{nexus_working_dir}}"
when: s_w.stat.exists

- name: Configure port
lineinfile:
dest="{{nexus_installation_dir}}/nexus-{{nexus_version}}/conf/nexus.properties"
line="application-port={{nexus_port}}"
regexp="application-port=.*"
state=present

- name: Configure workdir
lineinfile:
dest="{{nexus_installation_dir}}/nexus-{{nexus_version}}/conf/nexus.properties"
line="nexus-work={{nexus_working_dir}}"
regexp="nexus-work=.*"
state=present
2 changes: 2 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# vars file for ansible-nexus

0 comments on commit 8cc3355

Please sign in to comment.