-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall-spectrum.yml
461 lines (403 loc) · 13.2 KB
/
install-spectrum.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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
---
- name: check spectrum versions
hosts: localhost
become: no
vars:
preversion: "{{ lookup('file', dist_dir + '/requires.dat', errors='ignore') }}"
version: "{{ lookup('file', dist_dir + '/version.dat', errors='ignore') }}"
updateversion: "{{ lookup('file', update_dir + '/version.dat', errors='ignore') }}"
requires: "{{ lookup('file', update_dir + '/requires.dat', errors='ignore') }}"
tasks:
- name: check if base version requires an other version
debug:
msg: "you want to install {{ version }} which requires {{ preversion }}"
failed_when: preversion != ""
- name: check if update version requires the base version
debug:
msg: "base version : {{ version }} , {{ updateversion }} requires {{ requires }}"
failed_when: requires not in version
- name: install pre-requirements
hosts: all
become: yes
become_method: sudo
tasks:
- name: Ensure prerequirements are installed
yum:
name: "{{ packages }}"
state: present
vars:
packages:
- motif.x86_64
- motif-devel.x86_64
- ksh.x86_64
#- libnscl
- libnsl.x86_64
- abrt.x86_64
- elfutils-libelf.x86_64
- expat.x86_64
- fontconfig.x86_64
- freetype.x86_64
- glibc.x86_64
- libaio.x86_64
- libcanberra-gtk2.x86_64
- libgcc.x86_64
- libICE.x86_64
- libjpeg-turbo.x86_64
- libnsl.x86_64
- libpng.x86_64
- libSM.x86_64
- libstdc++.x86_64
- libuuid.x86_64
- libX11.x86_64
- libXau.x86_64
- libxcb.x86_64
- libxcrypt.x86_64
- libxcrypt.i686
- libXdmcp.x86_64
- libXext.x86_64
- libXfont2.x86_64
- libXft.x86_64
- libXi.x86_64
- libxkbfile.x86_64
- libXmu.x86_64
- libXp.x86_64
- libXrender.x86_64
- libXt.x86_64
- libXtst.x86_64
- ncurses.x86_64
#- ncurses-common-libs
- ncurses-compat-libs.x86_64
- ncurses-libs.x86_64
- nss-softokn-freebl.x86_64
- numactl-libs.x86_64
- perl-LWP-Protocol-https
- sssd-client.x86_64
- xorg-x11-fonts-misc
- xorg-x11-server-common.x86_64
- xorg-x11-xkb-utils.x86_64
- xterm.x86_64
- zlib.x86_64
- xorg-x11-server-Xvfb
- name: set SElinux to permissive mode
ansible.builtin.lineinfile:
path: /etc/selinux/config
regexp: '^SELINUX='
line: SELINUX=permissive
- name: stop firewalld
service:
name: firewalld
state: stopped
enabled: no
- name: remove empty lines from sudoers
ansible.builtin.replace:
path: /etc/sudoers
regexp: '^$'
replace: "##### replaced empty lines regarding Spectrum Bug"
- name: create spectrum owner
ansible.builtin.user:
name: "{{ spectrum_owner }}"
comment: Spectrum owner
shell: /bin/bash
password: "{{ spectrum_password | password_hash('sha512') }}"
update_password: on_create
- name: give spectrum owner access to sradmin.exe
ansible.builtin.lineinfile:
path: /etc/sudoers
line: "{{ spectrum_owner }} ALL={{ sradmin_dir }}/sradmin.exe"
- name: Show all the hosts in the current play
become: no
lineinfile:
create: yes
path: "tmp/hosts.tmp"
line: "{{ ansible_host }} {{ ansible_hostname }}"
delegate_to: localhost
- name: rollout hosts
lineinfile:
path: "/etc/hosts"
line: "{{ item }}"
loop: "{{ lookup('file', 'tmp/hosts.tmp').splitlines() }}"
# - name: rollout hosts to localhost
# lineinfile:
# path: "/etc/hosts"
# line: "{{ item }}"
# loop: "{{ lookup('file', 'tmp/hosts.tmp').splitlines() }}"
# delegate_to: localhost
- name: install SRAdmin
hosts: all
become: yes
become_method: sudo
gather_facts: no
tasks:
- name: create sradmin directory
ansible.builtin.file:
path: "{{ sradmin_dir }}"
state: directory
mode: '0755'
- name: copy sradmin.exe
copy:
src: "{{ dist_dir }}/sdic/linux/sradmin.exe"
dest: "{{ sradmin_dir }}"
mode: '0744'
- name: prepare rc2.d
copy:
src: "{{ dist_dir }}/sdic/linux/sradmin.rc2"
dest: /etc/init.d/sradmin
- name: chmod
ansible.builtin.file:
path: /etc/init.d/sradmin
mode: '0500'
- name: set sradmin home
ansible.builtin.lineinfile:
path: /etc/init.d/sradmin
line: SRADHOME={{ sradmin_dir }}
regexp: '^SRADHOME='
- name: set sudoers symlink
ansible.builtin.file:
src: /etc/sudoers
dest: "{{ sradmin_dir }}/sudoers"
owner: root
group: root
state: link
- name: enable and start sradmin
service:
name: sradmin
enabled: yes
- name: enable and start sradmin
service:
name: sradmin
state: started
- name: prepare hostargs
hosts: all
become: yes
become_method: sudo
gather_facts: yes
tasks:
- name: create install hostargs file
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.hostargs"
#flat: yes
line: remote_host={{ ansible_hostname }}
regexp: '^remote_host='
create: yes
- name: add landscape to hostargs
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.hostargs"
line: l_handle={{ l_handle }}
regexp: '^l_handle='
- name: add install directory to hostargs
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.hostargs"
line: install_dir={{ install_dir }}
regexp: '^install_dir='
- name: add install owner to hostargs
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.hostargs"
line: install_owner={{ spectrum_owner }}
regexp: '^install_owner='
- name: add install media path
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.hostargs"
line: vcd_path={{ dist_dir }}
regexp: '^vcd_path='
- name: add main location server
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.hostargs"
line: main_loc_serv={{ main_loc_serv }}
regexp: '^main_loc_serv='
- name: add install ss
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.hostargs"
line: ss_install={{ install_ss }}
regexp: '^ss_install='
- name: add install oneclick
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.hostargs"
line: oc_install={{ install_oneclick }}
regexp: '^oc_install='
- name: ignore disk space
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.hostargs"
line: ignore_disk_space=yes
regexp: '^ignore_disk_space='
- name: add locale
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.hostargs"
line: locale=en_US
regexp: '^locale='
- name: remove exclude parts
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.hostargs"
regexp: '^exclude_parts='
state: absent
- name: add exclude parts
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.hostargs"
line: exclude_parts=SA-RPT-MGR
regexp: '^exclude_parts='
when: install_srm == "no"
- name: copy hostargs to localhost
ansible.builtin.fetch:
src: /tmp/{{ ansible_hostname }}.hostargs
dest: ./
flat: yes
- name: create install password file
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.pw"
line: "{{ ansible_hostname }} {{ spectrum_owner }} spectrum"
create: yes
- name: copy password file to localhost
ansible.builtin.fetch:
src: /tmp/{{ ansible_hostname }}.pw
dest: ./
flat: yes
- name: fresh installation of Spectrum
hosts: all
become: yes
become_method: sudo
gather_facts: yes
tasks:
- name: get service facts
service_facts:
- name: start spectrum silent installation
ansible.builtin.command: "{{ dist_dir }}/sdic/sdiclinux.exe -h ./{{ ansible_hostname }}.hostargs -p ./{{ ansible_hostname }}.pw -accept "
delegate_to: 127.0.0.1
become: no
register: spec_out
when: ansible_facts.services["processd.service"] is not defined
failed_when: "'Installation failure' in spec_out.stdout"
changed_when: "'Installation successful' in spec_out.stdout"
# - name: print spectrum log
# debug:
# msg: "{{spec_out.stdout}}"
# when: spec_out.stdout is defined
#TODO: move hostrc after ssdb load on secondary
- name: create .hostrc template
become: no
lineinfile:
path: tmp/.hostrc
line: "{{ ansible_hostname }}"
create: yes
delegate_to: localhost
- name: copy .hostrc to spectrum server
#become: yes
#become_user: "{{ spectrum_owner }}"
ansible.builtin.copy:
src: tmp/.hostrc
dest: "{{ install_dir }}/"
# - name: modify .hostrc
# lineinfile:
# path: "{{ install_dir }}/.hostrc"
# line: "+"
- block:
- name: check for running SpectroSERVER
shell: ps -ef | grep SpectroSERVER | grep -v grep
ignore_errors: yes
args:
warn: no
changed_when: false
failed_when: false
register: ssstatus
- name: stop Spectroserver
become: yes
become_user: "{{ spectrum_owner }}"
command: "{{ install_dir }}/bin/stopSS.pl"
when: ssstatus.rc == 0
changed_when: ssstatus.rc == 0
- name: primary ssdbsave
become: yes
become_user: "{{ spectrum_owner }}"
command: "{{ install_dir }}/SS-Tools/SSdbsave -cmq /tmp/ansible-{{ ansible_hostname }}"
args:
chdir: "{{ install_dir }}/SS"
- name: get ssdb
become: yes
become_user: "{{ spectrum_owner }}"
fetch: src=/tmp/ansible-{{ ansible_hostname }}.SSdb dest=tmp/ flat=yes
when:
- is_secondary == "no"
- install_ss == "yes"
- block:
- name: upload ssdb
become: yes
become_user: "{{ spectrum_owner }}"
copy: src=tmp/ansible-{{ is_secondary_for }}.SSdb dest={{ install_dir }}/SS/
- name: load ssdb on secondary
become: yes
become_user: "{{ spectrum_owner }}"
command: "{{ install_dir }}/SS-Tools/SSdbload -ilq -add 20 ansible-{{ is_secondary_for }}.SSdb"
args:
chdir: "{{ install_dir }}/SS"
when: is_secondary == "yes"
- name: install update if requested
hosts: all
become: yes
become_method: sudo
gather_facts: no
vars:
updateversion: "{{ lookup('file', update_dir + '/version.dat', errors='ignore') }}"
tasks:
- name: check if update already installed
command: grep {{ updateversion }} {{ install_dir }}/Install-Tools/.history
ignore_errors: yes
args:
warn: no
changed_when: false
failed_when: false
register: updatecheck
# - debug:
# msg: "{{ updatecheck.rc }}"
- block:
- name: add install media path
ansible.builtin.lineinfile:
path: "/tmp/{{ ansible_hostname }}.hostargs"
line: vcd_path={{ update_dir }}
regexp: '^vcd_path='
- name: copy hostargs to localhost
ansible.builtin.fetch:
src: /tmp/{{ ansible_hostname }}.hostargs
dest: ./
flat: yes
- name: check for running SpectroSERVER
shell: ps -ef | grep SpectroSERVER | grep -v grep
ignore_errors: yes
args:
warn: no
changed_when: false
failed_when: false
register: ssstatus
# - debug:
# msg: "{{ ssstatus }}"
- name: stop Spectroserver
become: yes
become_user: "{{ spectrum_owner }}"
command: "{{ install_dir }}/bin/stopSS.pl"
when: ssstatus.rc == 0
changed_when: ssstatus.rc == 0
- name: start spectrum update silent installation
ansible.builtin.command: "{{ update_dir }}/sdic/sdiclinux.exe -h ./{{ ansible_hostname }}.hostargs -p ./{{ ansible_hostname }}.pw -accept "
delegate_to: 127.0.0.1
become: no
register: update_out
failed_when: "'Installation failure' in update_out.stdout or 'Failed to copy' in update_out.stdout"
changed_when: "'Installation successful' in update_out.stdout"
# - name: print spectrum log
# debug:
# msg: "{{update_out.stdout}}"
# when: update_out.stdout is defined
when: updatecheck.rc != 0
- name: finaly start Spectrum
hosts: all
gather_facts: no
tasks:
- name: start spectroserver
become: yes
become_user: "{{ spectrum_owner }}"
command: "{{ install_dir }}/bin/startSS.pl"
when: install_ss == "yes"
- name: start webapp
become: yes
become_user: "{{ spectrum_owner }}"
command: "{{ install_dir }}/webtomcat/bin/startWebTomcat.sh"
when:
- install_oneclick == "yes"
- enable_webapp == "yes"