-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsite.yml
98 lines (80 loc) · 2.5 KB
/
site.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
- name: Setup scenarioo server for Demos
hosts: mainserver
become: True # We need root rights to install stuff
#
# CONFIG & VARIABLES
#
pre_tasks:
- name: Load config.json
include_vars:
file: "{{ lookup('env', 'CONFIG_FILE') or 'config.json' }}"
name: config
- name: Get active branches # Active branche = branch with a config file under ./demos/
set_fact: active_branches="{{lookup('fileglob', './demos/*.json').split(',') | map('basename') | map('regex_replace', '(.*).json', '\\1') | list}}"
- name: Get currently deployed branches # Currently deployed = branch with scenarioo-<branch>.war in webapps
shell: ls -1 {{ config.tomcatFolder }}/webapps | grep '.war' | sed -e 's/^scenarioo-\(.*\).war/\1/'
register: deployed_branches_cmd
- set_fact: deployed_branches="{{ deployed_branches_cmd.stdout_lines }}"
- name: Update package cache
apt:
update_cache: yes
# See roles/ folder
roles:
- tomcat
- docker
- nginx
- manageUsers
tasks:
- name: Install unzip and jq (needed to extract artifact docu and read JSONs)
apt:
name: "{{ packages }}"
state: present
vars:
packages:
- jq
- unzip
#
# CLEANUP OLD BRANCHES
#
- name: Cleanup inactive branches
include_role:
name: cleanupBranch # Checkout roles/cleanupBranch/tasks/main.yml
when: branch not in active_branches
with_items: "{{ deployed_branches }}"
loop_control:
loop_var: branch
#
# ENSURE ACTIVE BRANCHES ARE DEPLOYED
#
- name: Deploy active branches
include_role:
name: deployBranch # Checkout roles/deployBranch/tasks/main.yml
with_items: "{{ active_branches }}"
loop_control:
loop_var: branch
#
# Restart Tomcat to prevent "Illegal access: this web application instance has been stopped already" in Tomcat Logs.
#
- name: Restart Tomcat
service:
name=tomcat8
state=restarted
#
# Reimport Builds
#
- name: Reimport Builds
include_role:
name: reimportBuilds # Checkout roles/deployBranch/tasks/main.yml
with_items: "{{ active_branches }}"
loop_control:
loop_var: branch
#
# UPDATE OVERVIEW PAGE
#
- name: Update overview page
copy:
src: overviewpage
dest: /scenarioo
owner: www-data
group: www-data