This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
site.yml
248 lines (241 loc) · 7 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
- name: Copy LGTM packages (controller)
hosts: controller
gather_facts: true
tags: packages
tasks:
- name: Install rsync
package:
name: rsync
state: latest
become: true
- name: Create temporary directory
file:
path: /tmp/lgtm-install
state: directory
- name: Download lgtm
synchronize:
src: files/lgtm/
dest: /tmp/lgtm-install/lgtm
delete: true
recursive: true
- name: Copy LGTM packages (non-controllers)
hosts: all:!controller
gather_facts: true
tags: packages
tasks:
- name: Install rsync
package:
name: rsync
state: latest
become: true
- name: Create temporary directory
file:
path: /tmp/lgtm-install
state: directory
- name: Download lgtm
synchronize:
src: files/lgtm/
dest: /tmp/lgtm-install/lgtm
delete: true
recursive: true
rsync_opts:
- '--exclude=lgtm-upgrade*'
- name: Generate configuration files
hosts: all
gather_facts: true
tags: config
tasks:
- name: Make state directory
file:
path: /tmp/lgtm-install/state
state: directory
- name: Cluster configuration
template:
src: templates/lgtm-cluster-config.yml
dest: /tmp/lgtm-install/state/lgtm-cluster-config.yml
- name: Manifest
copy:
src: "{{ lgtm_manifest_file }}"
dest: /tmp/lgtm-install/state/manifest.xml
- name: Copy certificate
copy:
src: "{{ lgtm_certificate_file }}"
dest: /tmp/lgtm-install/state/server.crt
mode: 0400
- name: copy key file
copy:
src: "{{ lgtm_key_file }}"
dest: /tmp/lgtm-install/state/server.key
mode: 0400
- name: Install Java 8 (deb)
apt:
name: openjdk-8-jre-headless
state: latest
become: true
when: "ansible_os_family == 'Debian' and ansible_distribution_major_version != '10'"
- name: Install Java 11 (deb)
apt:
name: openjdk-11-jre-headless
state: latest
become: true
when: ansible_os_family == 'Debian' and ansible_distribution_major_version == "10"
- name: Install Java (rpm)
yum:
name: java-1.8.0-openjdk-headless
state: present
become: true
when: ansible_os_family == 'RedHat'
- name: Run config generation
command: java -jar /tmp/lgtm-install/lgtm/lgtm-config-gen.jar --input /tmp/lgtm-install/state/lgtm-cluster-config.yml --output /tmp/lgtm-install/generated --overwrite generate
environment:
LGTM_CREDENTIALS_PASSWORD: "{{ lgtm_manifest_password }}"
- name: Install LGTM packages
hosts: all
tags: install
tasks:
- name: Stop LGTM components
shell: "lgtm-down || true"
become: true
- name: Run install-machine
shell: "LGTM_DONT_START=true /tmp/lgtm-install/generated/{{ lgtm_dummy_hostname }}/install-machine.sh"
become: true
- name: Set up worker build environment
hosts: worker
tags: buildtools
tasks:
- name: Install build packages (Debian/Ubuntu)
apt:
name:
- openjdk-8-jdk-headless
- gradle
- python3-pip
state: latest
become: true
when: "ansible_os_family == 'Debian' and ansible_distribution_major_version != '10'"
- name: Install build packages (Debian 10 only)
apt:
name:
- openjdk-11-jdk-headless
- gradle
- python3-pip
state: latest
become: true
when: ansible_os_family == 'Debian' and ansible_distribution_major_version == "10"
- name: Install build packages (RedHat only)
yum:
name:
- java-1.8.0-openjdk-devel
- python36-pip
state: latest
become: true
when: ansible_os_family == 'RedHat'
- name: Add Mono repository (RedHat only)
yum_repository:
name: mono
description: Mono
baseurl: https://download.mono-project.com/repo/centos7-stable/
gpgkey: https://download.mono-project.com/repo/xamarin.gpg
become: true
when: ansible_os_family == 'RedHat'
- name: Install build packages (all distributions)
package:
name:
- maven
- ant
- make
- clang
- gcc
- mono-devel
state: latest
become: true
- name: Set up python3 link (Redhat)
file:
src: /usr/bin/python3.6
dest: /usr/bin/python3
state: link
become: true
when: ansible_os_family == 'RedHat'
- name: Install Python 3 pip packages
command: pip3 install packaging virtualenv
become: true
- name: Copy git configuration
copy:
src: files/gitconfig
dest: /var/lib/lgtm-worker/.gitconfig
mode: 0400
owner: lgtm-worker
become: true
- name: Copy git credentials
template:
src: templates/git-credentials
dest: /var/lib/lgtm-worker/.git-credentials
mode: 0400
owner: lgtm-worker
become: true
- name: Initialise LGTM and start controller
hosts: controller
gather_facts: false
tags: init
tasks:
- name: Copy license file
copy:
src: files/license.dat
dest: /tmp/lgtm-install/init/
mode: 0400
- name: Copy LGTM integrations configuration
template:
src: templates/integrations.json
dest: /tmp/lgtm-install/integrations.json
mode: 0400
- name: Copy LGTM server configuration
template:
src: templates/server.json
dest: /tmp/lgtm-install/server.json
mode: 0400
- name: Start core services
command: lgtm-up --core-only
become: true
- name: lgtm-upgrade (1 of 5)
command: lgtm-upgrade --action CREATE --if-not-exists --config /etc/lgtm/config.json
become: true
- name: lgtm-upgrade (2 of 5)
command: lgtm-upgrade --action CONFIGURE --config /etc/lgtm/config.json
become: true
- name: lgtm-upgrade (3 of 5)
command: lgtm-upgrade --action FULL --schema-only
become: true
- name: lgtm-upgrade (4 of 5)
command: lgtm-upgrade --action INITIALIZE
become: true
- name: lgtm-upgrade (5 of 5)
command: lgtm-upgrade --action VALIDATE
become: true
- name: Install license
shell: lgtm-cli license --install /tmp/lgtm-install/init/*license*.dat
become: true
- name: Bring up lgtm on controller
command: lgtm-up
become: true
- name: Configure integrations
command: lgtm-cli patch-config /tmp/lgtm-install/integrations.json
become: true
- name: Configure web server
command: lgtm-cli patch-config /tmp/lgtm-install/server.json
become: true
- name: Start LGTM
hosts: all:!controller
tags: start
tasks:
- name: Run lgtm-up
command: lgtm-up
become: true
- name: Run data migrations
hosts: controller
tags: migrate
tasks:
- name: Upgrade (1 of 2)
command: lgtm-upgrade --action FULL
become: true
- name: Upgrade (2 of 2)
command: lgtm-upgrade --action CHECK
become: true