Skip to content

Commit 06da2fc

Browse files
author
Frank Neff
committed
Structural refactoring
1 parent 75a1d56 commit 06da2fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+109
-466
lines changed

.travis.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
sudo: required
3+
4+
env:
5+
- distribution: centos
6+
verions: 6
7+
#- distribution: centos
8+
# verions: 7
9+
#- distribution: ubuntu
10+
# version: xenial
11+
- distribution: ubuntu
12+
version: trusty
13+
#- distribution: debian
14+
# version: stretch
15+
#- distribution: debian
16+
# version: jessie
17+
18+
services:
19+
- docker
20+
21+
before_install:
22+
- 'sudo docker pull ${distribution}:${version}'
23+
- 'sudo docker build --no-cache --rm --file=travis/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible travis'
24+
25+
script:
26+
- container_id=$(mktemp)
27+
- 'sudo docker run --detach --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --volume="${PWD}":/etc/ansible/roles/nginx_role:ro ${distribution}-${version}:ansible > "${container_id}"'
28+
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/nginx_role/travis/test.yml --syntax-check'
29+
- 'sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/nginx_role/travis/test.yml'
30+
- >
31+
sudo docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=1 ansible-playbook -v /etc/ansible/roles/nginx_role/travis/test.yml
32+
| grep -q 'changed=0.*failed=0'
33+
&& (echo 'Idempotence test: pass' && exit 0)
34+
|| (echo 'Idempotence test: fail' && exit 1)
35+
- 'sudo docker rm -f "$(cat ${container_id})"'

README.md

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,64 @@
11
Ansible Java Deployment
22
=======================
33

4-
**Works for all the things packages to a zip / tarball (e.g. sbt native-packager stuff)**
4+
**Highly configurable deployment role for (Java/Scala) software packages**
55

6-
TBD
6+
Features
7+
--------
8+
9+
**Downloads and extracts almost any packaged deployment artifact**
10+
11+
Use it to download packages from your Artifactory, Nexus or static package hosting. By now, the role supports e.g.
12+
[SBT Native Packager](https://github.com/sbt/sbt-native-packager) packages,
13+
[Play Framework 2.x](https://www.playframework.com/) dists and virtually anything runnable packed in a zip or tar(.gz)
14+
archive.
15+
16+
**Generic application deployment**
17+
18+
The deployment consists of generic actions for downloading, unpacking and moving the application into place, configure
19+
logging, starting, stoping and restarting the application, and so on. All tasks and templates are highly configurable.
20+
21+
**Service management**
22+
23+
Multiple service runners like `upstart` or `systemd` can be used to register fully functional services for the deployed
24+
applications. Support for more application daemons is planned.
25+
26+
**Manage multiple application instances on a single machine**
27+
28+
The configurable directory structure, serive management and configuration allows to deploy the same application into
29+
multiple instances, even on the same server. This can be utilized to achive zero-downtime or A/B deployments.
30+
31+
Usage
32+
-----
33+
34+
As described above, the whole deployment is basically a configurable Ansible role. To use it, download it from GitHub or
35+
use Ansible Galaxy to install it directly into your existing playbook:
36+
37+
```
38+
ansible-galaxy install acmesoftware.java-deployment
39+
```
40+
41+
### Basic Example
42+
43+
If you just want to use it to deploy a simple app instance, there is very little minimal configuration to do. Add the
44+
following example to your playbook (e.g. `deploy.yml`):
45+
46+
47+
```yml
48+
- hosts: application-servers
49+
vars:
50+
deploy_artifact_url: "http://my.artifact.server/app-1.0-SNAPSHOT.zip"
51+
deploy_app_name: "my-application"
52+
deploy_service_start_command: "bin/{{ deploy_app_name }} -Dfoo=bar"
53+
roles:
54+
- acmesoftware.java-deployment
55+
```
56+
57+
Ideas / Todo
58+
------------
59+
60+
* Use Java Service Wraper (optional)
61+
* http://yajsw.sourceforge.net/
762
863
Tests
964
-----
@@ -16,25 +71,25 @@ deploy role.
1671
**Boot vagrant boxes**
1772
1873
```bash
19-
cd test/centos_6
74+
cd tests/centos_6
2075
vagrant up
2176
```
2277

2378
**Provide example play app for download:**
2479
```bash
25-
cd test/testapp/play-java-seed
80+
cd tests/testapp/play-java-seed
2681
sbt dist
2782
cd target/universal
2883
python -m SimpleHTTPServer
2984
```
3085
**Run test Playbook**
3186

3287
```bash
33-
cd test/playbook
88+
cd tests/playbook
3489
ansible-playbook -i hosts deploy.yml
3590
```
3691

3792
### Tested with
38-
* Ansible 2.4
39-
* Virtualbox 5.2
93+
* Ansible 2.3 / 2.4
94+
* Virtualbox 0.5 / 5.1 / 5.2
4095
* Vagrant 2.1 / 1.9.7

roles/deploy/defaults/main.yml renamed to defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Default variables for the playbook, override them for your own deployment
1+
# Default variables for the playbook, override them in your playbook or inventory
22

33
# General Settings
44
###############################################
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

roles/deploy/tasks/preinstall.yml renamed to tasks/preinstall.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
group: "{{ deploy_app_group }}"
1616
state: present
1717

18+
- name: "Preinstall - Ensure base directory {{ deploy_dir_base }}"
19+
become: yes
20+
file:
21+
path: "{{ deploy_dir_base }}"
22+
state: directory
23+
owner: "{{ deploy_app_user }}"
24+
group: "{{ deploy_app_group }}"
25+
1826
- name: "Preinstall - Ensure directories for instance {{ deploy_instance_nr }}"
1927
become: yes
2028
become_user: "{{ deploy_app_user }}"
@@ -24,7 +32,6 @@
2432
owner: "{{ deploy_app_user }}"
2533
group: "{{ deploy_app_group }}"
2634
with_items:
27-
- "{{ deploy_dir_base }}"
2835
- "{{ deploy_download_dir }}"
2936
- "{{ deploy_dir_instances }}"
3037
- "{{ deploy_dir_instance }}"

0 commit comments

Comments
 (0)