Skip to content

Commit

Permalink
infra: Add script to deploy xsnd
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexITC committed Nov 24, 2018
1 parent 449579d commit 94967d4
Show file tree
Hide file tree
Showing 8 changed files with 205 additions and 0 deletions.
9 changes: 9 additions & 0 deletions infra/deployment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Deployment

This folder contains all the required scripts to deploy the projects.

These scripts were tested with ansible 2.6.4, higher versions should work too, it might not work with smaller versions.

## xsnd
Execute the following command to deploy the application to a test server:
- `ansible-playbook -i test-hosts.ini --ask-become-pass --vault-password-file .vault xsnd.yml`
13 changes: 13 additions & 0 deletions infra/deployment/config/xsn.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$ANSIBLE_VAULT;1.1;AES256
30393735346666366537626363646562353633393564306431656130303833616366623930393235
3239336437316235373561396664663334373963326632350a366632633935323432323233353333
66356433613636393130666637663062386565303561303531653231393265663262343532376537
3030333163396534620a393962306261376539643265346138626334316532396664306263623763
64626338396565363433383134326264386630393632656465323566636664313134393535633839
38363832646366376633333562623034393034306266343037383839376435613165626330616530
34663630313139383436316535386134333163353131633630666235343766333661363839666230
63646138653866666234646161333662306361393437336161376436613432653234383535346266
64663738383665393562633562616137643962613033323137643234653063303663656638633062
37646163663436653030663831633031336164656662393833366133303163613163346539306362
39343731623038623163323339343134663833613565343733386663383839306362386339333165
65623139313335323662
16 changes: 16 additions & 0 deletions infra/deployment/roles/java8-oracle/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
galaxy_info:
author: Malk’Zameth
description: Java8 from Oracle, using the webupd8 ppa
license: GPLv3
min_ansible_version: 1.9
platforms:
- name: Ubuntu
versions:
- saucy
- trusty
categories:
- development
- system

dependencies: []
28 changes: 28 additions & 0 deletions infra/deployment/roles/java8-oracle/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# based on https://github.com/malk/ansible-java8-oracle
- name: Install add-apt-repostory
become: yes
apt:
name: software-properties-common
state: latest

- name: Add Oracle Java Repository
become: yes
apt_repository:
repo: ppa:webupd8team/java
state: present

- name: Accept Java 8 License
become: yes
debconf:
name: 'oracle-java8-installer'
question: 'shared/accepted-oracle-license-v1-1'
value: 'true'
vtype: 'select'

- name: Install Oracle Java 8
become: yes
apt: name={{item}} state=latest
with_items:
- oracle-java8-installer
- ca-certificates
- oracle-java8-set-default
10 changes: 10 additions & 0 deletions infra/deployment/roles/ubuntu-16-04/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

- name: Ensure python2 is present (required by ubuntu 16.04)
become: yes
raw: apt-get -y install python-simplejson

- name: Install unzip tool
become: yes
apt:
name: unzip
state: latest
15 changes: 15 additions & 0 deletions infra/deployment/systemd-services/xsn-rpc.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=XSN RPC Server

[Service]
Type=simple
WorkingDirectory=/home/xsn/
StandardOutput=tty
StandardError=tty
User=xsn
ExecStart=/home/xsn/app/xsnd

Restart=on-failure

[Install]
WantedBy=multi-user.target
8 changes: 8 additions & 0 deletions infra/deployment/test-hosts.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[server]
test-server

[xsnd]
test-server

[postgres]
test-server
106 changes: 106 additions & 0 deletions infra/deployment/xsnd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
- hosts: xsnd
gather_facts: no
roles:
- ubuntu-16-04

vars:
- xsn_user: xsn
- xsn_group: xsn
- xsn_home: /home/xsn
- xsn_config_dir: /home/xsn/.xsncore
- xsn_download_url: https://github.com/X9Developers/XSN/releases/download/v1.0.17/xsn-1.0.17-x86_64-linux-gnu.tar.gz
- xsn_download_dest: /home/dummy/xsn.tar.gz
- xsn_download_checksum: sha1:550e5b2e8f2d19a88915c167e333c732ecfef542
- xsn_unarchive_dest: /home/xsn/app

tasks:
- name: Create the xsn group
become: yes
group:
name={{ xsn_group }}
state=present

- name: Create the xsn user
become: yes
user:
name={{ xsn_user }}
group={{ xsn_group }}
state=present
system=yes

- name: Create the app directory
become: yes
file:
path={{ xsn_home }}/app
state=directory
owner={{ xsn_user }}
group={{ xsn_group }}

- name: Create the config directory
become: yes
file:
path={{ xsn_config_dir }}
state=directory
owner={{ xsn_user }}
group={{ xsn_group }}

- name: Download the xsnd
get_url:
url={{ xsn_download_url }}
dest={{ xsn_download_dest }}
checksum={{ xsn_download_checksum }}

- name: Unpack the application
become: yes
unarchive:
remote_src=yes
src={{ xsn_download_dest }}
dest={{ xsn_unarchive_dest }}
owner={{ xsn_user }}
group={{ xsn_group }}

- name: Move the application to the right folder
become: yes
command: mv {{ xsn_unarchive_dest }}/xsn-1.0.17/bin/xsnd {{ xsn_unarchive_dest }}

- name: Set the application config
become: yes
copy:
src=config/xsn.conf
dest={{ xsn_config_dir }}/xsn.conf
owner={{ xsn_user }}
group={{ xsn_group }}

- name: Set the application files permissions
become: yes
file:
dest={{ xsn_home }}
owner={{ xsn_user }}
group={{ xsn_group }}
recurse=yes

- name: Add the systemd service
become: yes
copy:
src: systemd-services/xsn-rpc.service
dest: /etc/systemd/system/
owner: root
group: root

- name: Pick up systemd changes
become: yes
systemd:
daemon_reload: yes

- name: Restart the application
become: yes
systemd:
name: xsn-rpc
state: restarted

- name: Enable the application to run on system startup
become: yes
systemd:
name: xsn-rpc
enabled: yes

0 comments on commit 94967d4

Please sign in to comment.