-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathmain.yml
53 lines (47 loc) · 1.67 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
---
################
# Java_install #
################
- name: Test if Java is already installed version {{ jdk_version }}
win_stat:
path: 'C:\openjdk\jdk-{{ jdk_version }}\bin'
register: java_installed
tags: Java_install
- name: Use adoptium API if release is available at adoptium
set_fact:
api_url: api.adoptium.net
api_vendor: eclipse
when:
- jdk_version == '8' or jdk_version == '11' or ( jdk_version | int >= 17)
tags: adoptopenjdk_install
- name: Use adoptopenjdk API if release is not supported by adoptium
set_fact:
api_url: api.adoptopenjdk.net
api_vendor: adoptopenjdk
when:
- jdk_version == 10 or jdk_version == 16
tags: adoptopenjdk_install
- name: Download Temurin JDK {{ jdk_version }}
win_get_url:
url: https://{{ api_url }}/v3/binary/latest/{{ jdk_version }}/ga/windows/x64/jdk/{{ bootjdk }}/normal/{{ api_vendor }}?project=jdk
dest: 'C:\temp\jdk-{{ jdk_version }}.zip'
when: not java_installed.stat.exists
tags: Java_install
- name: Install Java{{ jdk_version }}
win_unzip:
src: C:\temp\jdk-{{ jdk_version }}.zip
dest: C:\Program Files\Java
when: not java_installed.stat.exists
tags: Java_install
- name: Create symlink to directory without spaces if not already there
win_shell: for /D %a in ("C:\Program Files\Java\jdk-{{ jdk_version }}*") do IF NOT EXIST "C:\openjdk\jdk-{{ jdk_version }}" MKLINK /D "C:\openjdk\jdk-{{ jdk_version }}" "%a"
args:
executable: cmd.exe
creates: 'C:\openjdk\jdk-{{ jdk_version }}'
tags: Java_install
- name: Remove temp zip file
win_file:
path: 'C:\temp\jdk-{{ jdk_version }}.zip'
state: absent
when: not java_installed.stat.exists
tags: Java_install