-
Notifications
You must be signed in to change notification settings - Fork 166
/
main.yml
341 lines (290 loc) · 11.2 KB
/
main.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
---
#
# fetches jenkins and make sure it is started properly
#
- name: set jobs_env from jobs_variants.{{ arch }}
set_fact:
jobs_env: "{{ jobs_variants[arch] }}"
when: jobs_env is undefined and server_jobs is undefined and arch in jobs_variants
- name: set jobs_env from jobs_variants.{{ os|stripversion }}
set_fact:
jobs_env: "{{ jobs_variants[os|stripversion] }}"
when: jobs_env is undefined and server_jobs is undefined and os|stripversion in jobs_variants
- name: set jobs_env from server_jobs or ansible_processor_vcpus or ansible_processor_cores
set_fact:
jobs_env: "{{ server_jobs|default(ansible_processor_vcpus)|default(ansible_processor_cores) }}"
when: jobs_env is undefined and (server_jobs is defined or ansible_processor_vcpus is defined or ansible_processor_cores is defined)
- name: set jobs_env to fall-back value of 2
set_fact:
jobs_env: "2"
when: jobs_env is undefined
- name: add ::1 to /etc/hosts for ipv6 compat
when: not os|startswith("zos") and not os|startswith("ibmi")
lineinfile:
dest: /etc/hosts
state: present
line: ::1 localhost.localdomain localhost
- name: run scaleway armv7 jenkins-worker setup
when: "'scaleway-ubuntu1804-armv7l' in inventory_hostname"
include_tasks: "{{ role_path }}/tasks/partials/scaleway-armv7.yml"
- name: prepare installing tap2junit
when: type != "release"
include_tasks: "{{ pip_include }}"
loop_control:
loop_var: pip_include
with_first_found:
- files:
- "{{ role_path }}/tasks/partials/tap2junit/{{ os }}.yml"
- "{{ role_path }}/tasks/partials/tap2junit/{{ os|stripversion }}.yml"
- "{{ role_path }}/tasks/partials/tap2junit/pip.yml"
skip: true
- name: install root certificates
copy:
dest: "{{ home }}/{{ server_user }}/ca-bundle.crt"
force: yes
src: "{{ role_path }}/files/cacert.pem"
register: root_certs
when: os|startswith("zos")
- name: tag root certificate file on z/OS
shell:
cmd: "chtag -t -c iso8859-1 {{ root_certs.dest }}"
when: os|startswith("zos")
- name: download agent.jar
get_url:
url: "{{ jenkins_agent_jar }}"
dest: '{{ home }}/{{ server_user }}/agent.jar'
mode: 0644
timeout: 60
force: yes
notify: restart Jenkins
- name: Resolver | ipnodes needs to be present on zos, similar to hosts file
when: os|startswith("zos")
copy:
content: "127.0.0.1 localhost\n::1 localhost\n"
dest: '{{ home }}/{{ server_user }}/ipnodes.utf8'
register: ipnodes
- name: Resolver | convert ipnodes to ebcdic
when: os|startswith("zos")
shell:
cmd: "iconv -f utf8 -t ibm-1047 {{ ipnodes.dest }} > /etc/ipnodes"
creates: "/etc/ipnodes"
- name: Resolver | set DNS resolving priorities for zos
when: os|startswith("zos")
copy:
content: "LOOKUP LOCAL DNS"
dest: '{{ home }}/{{ server_user }}/resolve.utf8'
register: resolve
- name: Resolver | convert resolve to ebcdic
when: os|startswith("zos")
shell:
cmd: "iconv -f utf8 -t ibm-1047 {{ resolve.dest }} > {{ (resolve.dest | splitext)[0] }}"
creates: "{{ (resolve.dest | splitext)[0] }}"
- name: render git wrapper into place
when: os|startswith("zos")
template:
src: "{{ role_path }}/templates/git-wrapper.j2"
dest: "{{ home }}/{{ server_user }}/git-wrapper"
mode: "{{ jenkins.mode|default('0655') }}"
register: gitwrapper
- name: tag git-wrapper as ascii
when: os|startswith("zos") and gitwrapper.changed
shell:
cmd: "chtag -t -c iso8859-1 {{ gitwrapper.dest }}"
- stat: path={{ home }}/{{ server_user }}/runAsciiBash
register: runAsciiBashExists
- name: render runAsciiBash into place - part 1
when: os|startswith("zos")
template:
src: "{{ role_path }}/templates/runAsciiBash.c.j2"
dest: "{{ home }}/{{ server_user }}/runAsciiBash.c"
mode: "{{ jenkins.mode|default('0644') }}"
register: asciibashc
- name: tag runAsciiBash source as ascii
when: os|startswith("zos") and asciibashc.changed
shell:
cmd: "chtag -t -c iso8859-1 {{ asciibashc.dest }}"
- name: render runAsciiBash into place - part 2
when: os|startswith("zos")
template:
src: "{{ role_path }}/templates/gen_runAsciiBash.j2"
dest: "{{ home }}/{{ server_user }}/gen_runAsciiBash.sh"
mode: "{{ jenkins.mode|default('0655') }}"
register: genasciibash
- name: tag runAsciiBash build script as ascii
when: os|startswith("zos") and genasciibash.changed
shell:
cmd: "chtag -t -c iso8859-1 {{ genasciibash.dest }}"
- name: render runAsciiBash into place - part 3
when:
- os|startswith("zos")
- asciibashc.changed or genasciibash.changed or
runAsciiBashExists.stat.exists == False
shell: "sh {{ home }}/{{ server_user }}/gen_runAsciiBash.sh"
# We should probably create a git reference repository for all hosts but
# limit for now to newer ones where we know we have enough disk space.
- name: create directory for git reference repository
ansible.builtin.file:
group: "{{ server_user }}"
owner: "{{ server_user }}"
path: "{{ git_reference_path | dirname }}"
state: directory
when: os == 'rhel8' or os == 'rhel7'
- name: create git reference repository
ansible.builtin.command:
chdir: "{{ git_reference_path | dirname }}"
cmd: git clone --mirror https://github.com/nodejs/node "{{ git_reference_path | basename }}"
creates: "{{ git_reference_path }}"
become: yes
become_user: "{{ server_user }}"
when: os == 'rhel8' or os == 'rhel7'
- name: render init script into place
notify: restart Jenkins
template:
src: "{{ jenkins.src }}"
dest: "{{ jenkins.dest }}"
mode: "{{ jenkins.mode|default('0644') }}"
register: initscript
- name: convert init script to ebcdic on z/OS
when: os|startswith("zos")
shell:
cmd: "iconv -f utf8 -t ibm-1047 {{ initscript.dest }} > {{ (initscript.dest | splitext)[0] }}"
# TODO - Should this run on every machine?
- name: copy start.sh to {{ home }}/{{ server_user }}/start.sh
when: os|startswith("macos")
template:
src: "start.j2"
dest: "{{ home }}/{{ server_user }}/start.sh"
mode: "0755"
- name: import manifest to svcadm
when: os|startswith("smartos")
raw: "svccfg import {{ jenkins.dest }}"
- name: install cmake - create directory - part 1
when: os|startswith("zos")
file:
owner: "{{ server_user }}"
mode: "0775"
path: "{{ home }}/{{ server_user }}/cmake"
state: directory
- name: install cmake - download tarball - part 2
when: os|startswith("zos")
shell:
chdir: "{{ home }}/{{ server_user }}/cmake"
cmd: "su -s {{ server_user }} -c 'curl -sL -o cmake-v3.5.1-zos.tar.gz https://github.com/fjeremic/CMake/archive/v3.5.1-zos.tar.gz'"
creates: "{{ home }}/{{ server_user }}/cmake/cmake-v3.5.1-zos.tar.gz"
- name: install cmake - extract tarball - part 3
when: os|startswith("zos")
shell:
chdir: "{{ home }}/{{ server_user }}/cmake"
cmd: "su -s {{ server_user }} -c 'gzip -dc < cmake-v3.5.1-zos.tar.gz | pax -r -o from=iso8859-1,to=ibm-1047'"
creates: "{{ home }}/{{ server_user }}/cmake/CMake-3.5.1-zos"
- name: install cmake - create temp directory - part 4
when: os|startswith("zos")
file:
owner: "{{ server_user }}"
path: "{{ home }}/{{ server_user }}/temp"
state: directory
- name: install cmake - create install directory - part 5
when: os|startswith("zos")
file:
owner: "{{ server_user }}"
path: "{{ home }}/{{ server_user }}/local"
state: directory
- name: install cmake - build - part 6
when: os|startswith("zos")
environment:
_C89_CCMODE: 1
_CC_CCMODE: 1
_CEE_RUNOPTS: FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)
_CXX_CCMODE: 1
_TAG_REDIR_ERR: txt
_TAG_REDIR_IN: txt
_TAG_REDIR_OUT: txt
PATH: "{{ cmake_path_env }}"
TMPDIR: "{{ home }}/{{ server_user }}/temp"
shell:
chdir: "{{ home }}/{{ server_user }}/cmake/CMake-3.5.1-zos"
cmd: "su -s {{ server_user }} -c './bootstrap --prefix={{ home }}/{{ server_user }}/local --verbose && make -j8 VERBOSE=1 && make install'"
creates: "{{ home }}/{{ server_user }}/local/bin/cmake"
- name: render gyp into place - Create directory - part 1
when: os|startswith("zos13")
file:
path: "{{ home }}/{{ server_user }}/gyp"
state: directory
# zos does not support https:// with git and chromium
# only provides an https endpoint. We store on ci
# instead
- name: render gyp into place - get the zip - part 2
when: os|startswith("zos13")
uri:
url: "http://ci.nodejs.org/downloads/zos/gyp.tar.gz"
dest: "{{ home }}/{{ server_user }}/gyp/gyp.tar.gz"
creates: "{{ home }}/{{ server_user }}/gyp/gyp.tar"
# note that unarchive does not work (does not like version
# of tar) so just execute commands directly
- name: render gyp into place - decompress - part 3
when: os|startswith("zos13")
command: "gunzip gyp.tar.gz"
args:
chdir: "{{ home }}/{{ server_user }}/gyp"
creates: "{{ home }}/{{ server_user }}/gyp/gyp.tar"
# the user option does not seem to work so
# do that change in separate step below
- name: render gyp into place - extract - part 4
when: os|startswith("zos13")
command: "pax -rf gyp.tar -o from=iso8859-1,to=ibm-1047"
args:
chdir: "{{ home }}/{{ server_user }}/gyp"
creates: "{{ home }}/{{ server_user }}/gyp/LICENSE"
- name: render gyp into place - fix up ownership - part 5
when: os|startswith("zos13")
command: "chown -R {{ server_user }} {{ home }}/{{ server_user }}/gyp"
# This has to be done before the `service` (and similar) commands because
# java is needed to start the service
- name: enable jenkins at startup - general
ansible.builtin.service:
name: jenkins
enabled: yes
state: started
when:
- not os|startswith("aix")
- not os|startswith("ibmi")
- not os|startswith("macos")
- not os|startswith("zos")
- name: Unload org.nodejs.osx.jenkins.plist from launchctl
when: os|startswith("macos")
command: launchctl unload /Library/LaunchDaemons/org.nodejs.osx.jenkins.plist
- name: Load org.nodejs.osx.jenkins.plist into launchctl
when: os|startswith("macos")
command: launchctl load /Library/LaunchDaemons/org.nodejs.osx.jenkins.plist
- name: Start org.nodejs.osx.jenkins.plist
when: os|startswith("macos")
command: launchctl start org.nodejs.osx.jenkins
# lineinfile does not work on zos due to character conversions
# the inserted line ends up in the wrong character set. We
# tried a few variations to work around this without
# success so for now do it the hard way.
- name: enable jenkins at startup - zos - part 1
when: os|startswith("zos")
template:
src: "{{ role_path }}/templates/zos_rc_patch.j2"
dest: "{{ home }}/{{ server_user }}/rc_patch"
mode: "{{ jenkins.mode|default('0644') }}"
register: rcpatch
- name: tag rc_patch as ascii
when: os|startswith("zos") and rcpatch.changed
shell:
cmd: "chtag -t -c iso8859-1 {{ rcpatch.dest }}"
- name: enable jenkins at startup - zos - part 2
when: os|startswith("zos")
template:
src: "{{ role_path }}/templates/zos_rc_patch_apply.j2"
dest: "{{ home }}/{{ server_user }}/rc_patch_apply.sh"
mode: "{{ jenkins.mode|default('0655') }}"
register: rcpatchapply
- name: tag rc_patch_apply.sh as ascii
when: os|startswith("zos") and rcpatchapply.changed
shell:
cmd: "chtag -t -c iso8859-1 {{ rcpatchapply.dest }}"
- name: enable jenkins at startup - zos - part 3
when: os|startswith("zos")
shell: "sh {{ home }}/{{ server_user }}/rc_patch_apply.sh"