-
-
Notifications
You must be signed in to change notification settings - Fork 101
/
main.yml
292 lines (262 loc) · 8.9 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
---
##############################################################
# ansible install adoptopenjdk into /usr/lib/jvm/JDK_VERSION #
##############################################################
# Conditions:
# Check if target is installed
# Proceed with installing to /usr/lib/jvm
- name: Set path variable when jdk_version == 8
set_fact:
path: /usr/lib/jvm/jdk8
when:
- ansible_distribution != "MacOSX"
- jdk_version == 8
tags: adoptopenjdk_install
- name: Set path variable when jdk_version != 8
set_fact:
path: /usr/lib/jvm/jdk-{{ jdk_version }}
when:
- jdk_version != 8
- ansible_distribution != "MacOSX"
tags: adoptopenjdk_install
- name: Set path variable (macOS)
set_fact:
path: "/Library/Java/JavaVirtualMachines/jdk-{{ jdk_version }}"
when: ansible_distribution == "MacOSX"
tags: adoptopenjdk_install
- name: Set api_architecture variable
set_fact:
api_architecture: "{{ ansible_architecture }}"
tags: adoptopenjdk_install
- name: Set api_architecture variable for x86_64
set_fact:
api_architecture: x64
when:
- ansible_architecture == "x86_64"
tags: adoptopenjdk_install
- name: Set api_architecture variable for sun4v
set_fact:
api_architecture: sparcv9
when:
- ansible_architecture == "sun4v"
tags: adoptopenjdk_install
- name: Set api_architecture variable for i386
set_fact:
api_architecture: x64
when:
- ansible_os_family != "Darwin"
- ansible_architecture == "i386"
tags: adoptopenjdk_install
# Download x64 binaries until we have arm64 binaries available
- name: Set x64 api_architecture variable for macOS Arm64
set_fact:
api_architecture: x64
when:
- ansible_os_family == "Darwin"
- ansible_architecture == "arm64"
- jdk_version < 17
- jdk_version != 11
tags: adoptopenjdk_install
- name: Set aarch64 api_architecture variable for macOS Arm64
set_fact:
api_architecture: aarch64
when:
- ansible_os_family == "Darwin"
- ansible_architecture == "arm64"
- jdk_version >= 17 or jdk_version == 11
tags: adoptopenjdk_install
- name: Set api_architecture variable for armv7l
set_fact:
api_architecture: arm
when:
- ansible_architecture == "armv7l"
tags: adoptopenjdk_install
- name: Print api_architecture var
debug:
var: api_architecture
tags: adoptopenjdk_install
- name: Checking for /usr/lib/jvm
stat: path=/usr/lib/jvm
register: usr_lib_jvm_exists
when:
- ansible_distribution != "MacOSX"
tags: adoptopenjdk_install
- name: Creating /usr/lib/jvm if not found
file:
path: /usr/lib/jvm
state: directory
owner: root
mode: 0755
when:
- ansible_distribution != "MacOSX"
- not usr_lib_jvm_exists.stat.exists
tags: adoptopenjdk_install
- name: Check if jdk-{{ jdk_version }} is already installed in the target location
shell: ls -ld {{ path }} >/dev/null 2>&1
failed_when: false
register: adoptopenjdk_installed
changed_when: false
tags:
- adoptopenjdk_install
- skip_ansible_lint
- name: Install latest release if one not already installed
unarchive:
src: https://api.adoptopenjdk.net/v3/binary/latest/{{ jdk_version }}/ga/linux/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk
dest: /usr/lib/jvm
remote_src: yes
retries: 3
delay: 5
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed
when:
- ansible_distribution != "MacOSX"
- not ((ansible_distribution == "RedHat" or ansible_distribution == "CentOS") and ansible_distribution_major_version == "6")
- ansible_os_family != "Solaris"
- adoptopenjdk_installed.rc != 0
tags: adoptopenjdk_install
- name: Install latest release if one not already installed (alpine-linux)
unarchive:
src: https://api.adoptopenjdk.net/v3/binary/latest/{{ jdk_version }}/ga/alpine-linux/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk
dest: /usr/lib/jvm
remote_src: yes
retries: 3
delay: 5
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed
when:
- ansible_distribution == "Alpine"
- adoptopenjdk_installed.rc != 0
tags: adoptopenjdk_install
# CentOS6 needs it's own task so it can use a different python interpreter.
# See: https://github.com/adoptium/infrastructure/issues/1877
- name: Install latest release if not already installed (CentOS6)
unarchive:
src: https://api.adoptopenjdk.net/v3/binary/latest/{{ jdk_version }}/ga/linux/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk
dest: /usr/lib/jvm
remote_src: yes
vars:
ansible_python_interpreter: /usr/local/python2/bin/python2.7
retries: 3
delay: 5
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed
when:
- (ansible_distribution == "RedHat" or ansible_distribution == "CentOS") and ansible_distribution_major_version == "6"
- adoptopenjdk_installed.rc != 0
tags: adoptopenjdk_install
- name: Install latest release if one not already installed (macOS)
get_url:
url: https://api.adoptopenjdk.net/v3/installer/latest/{{ jdk_version }}/ga/mac/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk
dest: /tmp/{{ jdk_version }}-installer.pkg
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed
when:
- ansible_distribution == "MacOSX"
- adoptopenjdk_installed.rc != 0
- jdk_version != 10
tags: adoptopenjdk_install
- name: Run installer (macOS)
shell: sudo installer -pkg /tmp/{{ jdk_version }}-installer.pkg -target /
when:
- ansible_distribution == "MacOSX"
- adoptopenjdk_installed.rc != 0
- jdk_version != 10
tags: adoptopenjdk_install
- name: Download tarball when installer is not available (MacOS)
unarchive:
src: https://api.adoptopenjdk.net/v3/binary/latest/{{ jdk_version }}/ga/mac/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk
remote_src: yes
dest: /Library/Java/JavaVirtualMachines/
become: yes
become_user: root
retries: 3
delay: 5
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed
when:
- ansible_distribution == "MacOSX"
- adoptopenjdk_installed.rc != 0
- jdk_version == 10
tags: adoptopenjdk_install
# Boot JDK will be installed in temurin directory. Playbooks, build and (possibly) test scripts will look for an adoptopenjdk directory
# https://github.com/adoptium/infrastructure/issues/2281#issuecomment-1059322275
- name: Find bootjdk install directory (MacOS)
find:
paths: /Library/Java/JavaVirtualMachines
patterns:
- "^adoptopenjdk-{{ jdk_version }}.jdk"
- "^temurin-{{ jdk_version }}.jdk"
- "^jdk-{{ jdk_version }}.*"
use_regex: yes
file_type: directory
register: bootjdk_install_dir
when:
- ansible_distribution == "MacOSX"
- adoptopenjdk_installed.rc != 0
tags: adoptopenjdk_install
- name: Create jdk symlink to bootjdk install directory (MacOS)
file:
src: '{{ bootjdk_install_dir.files[0].path }}'
dest: '{{ path }}'
state: link
owner: root
group: wheel
become: yes
become_user: root
become_method: sudo
when:
- ansible_distribution == "MacOSX"
- adoptopenjdk_installed.rc != 0
tags: adoptopenjdk_install
- name: Install latest release if one not already installed (Solaris)
command: wget https://api.adoptopenjdk.net/v3/binary/latest/{{ jdk_version }}/ga/solaris/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk -O /tmp/jdk-{{ jdk_version }}.tar.gz
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed
when:
- ansible_os_family == "Solaris"
- adoptopenjdk_installed.rc != 0
tags: adoptopenjdk_install
- name: Extract latest release if one not already installed (Solaris)
command: tar -xf /tmp/jdk-{{ jdk_version }}.tar.gz -C /usr/lib/jvm
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed
when:
- ansible_os_family == "Solaris"
- adoptopenjdk_installed.rc != 0
tags: adoptopenjdk_install
- name: Get {{ path }}* full path name
shell: set -o pipefail | ls -ld {{ path }}* 2>/dev/null | awk '{print $9}'
register: adoptopenjdk_dir
changed_when: false
when:
- ansible_distribution != "MacOSX"
- adoptopenjdk_installed.rc != 0
tags: adoptopenjdk_install
- name: Create symlink to major version
file:
src: '{{ adoptopenjdk_dir.stdout }}'
dest: '{{ path }}'
state: link
when:
- ansible_distribution != "MacOSX"
- adoptopenjdk_installed.rc != 0
tags: adoptopenjdk_install
- name: Create symlink to major version
file:
src: '{{ adoptopenjdk_dir.stdout }}'
dest: '{{ path }}'
state: link
when:
- ansible_distribution != "MacOSX"
- adoptopenjdk_installed.rc != 0
tags: adoptopenjdk_install
- name: Chown {{ path }}*
file:
path: '{{ adoptopenjdk_dir.stdout }}'
state: directory
owner: root
recurse: yes
when:
- ansible_distribution != "MacOSX"
- adoptopenjdk_installed.rc != 0
tags: adoptopenjdk_install