Skip to content

Commit

Permalink
Use correct API for each JDK version
Browse files Browse the repository at this point in the history
Signed-off-by: Stewart X Addison <sxa@redhat.com>
  • Loading branch information
sxa committed Feb 15, 2024
1 parent 3c11bec commit f4644aa
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 47 deletions.
10 changes: 5 additions & 5 deletions ansible/playbooks/AdoptOpenJDK_Unix_Playbook/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,19 @@
- ansible_distribution != "Solaris"
- ansible_architecture != "riscv64"
tags: build_tools
- role: adoptopenjdk_install # JDK20 Build Bootstrap
jdk_version: 19
- role: adoptopenjdk_install # JDK21 Build Bootstrap
jdk_version: 20
when:
- ansible_distribution != "Alpine"
- ansible_distribution != "Solaris"
- ansible_architecture != "riscv64"
tags: build_tools
- role: adoptopenjdk_install # JDK21 Build Bootstrap
jdk_version: 20
- role: adoptopenjdk_install # JDK22 Build Bootstrap
jdk_version: 21
when:
- ansible_distribution != "Alpine"
- ansible_distribution != "Solaris"
- ansible_architecture != "riscv64"
- ansible_architecture != "armv7l"
tags: build_tools
- role: Nagios_Plugins # AdoptOpenJDK Infrastructure
tags: [nagios_plugins, adoptopenjdk]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
---
##############################################################
# ansible install adoptopenjdk into /usr/lib/jvm/JDK_VERSION #
##############################################################
###############################################################
# ansible install adopt binary into /usr/lib/jvm/JDK_VERSION #
###############################################################

# Conditions:
# Check if target is installed
# Proceed with installing to /usr/lib/jvm

- name: Use adoptium API if release is available at adoptium
set_fact:
api_url: https://api.adoptium.net
when:
- ( jdk_version == 8 || jdk_version == 11 || jdk_version >= 17 )
tags: adoptopenjdk_install

- name: Use adoptopenjdk API if release is not supported by adoptium
set_fact:
api_url: https://api.adoptopenjdk.net
when:
- ! ( jdk_version == 8 || jdk_version == 11 || jdk_version >= 17 )
tags: adoptopenjdk_install

- name: Set path variable when jdk_version == 8
set_fact:
path: /usr/lib/jvm/jdk8
Expand Down Expand Up @@ -134,38 +148,27 @@
- ansible_distribution != "MacOSX"
- not ((ansible_distribution == "RedHat" or ansible_distribution == "CentOS") and ansible_distribution_major_version == "6")
- ansible_os_family != "Solaris"
- not (ansible_architecture == "riscv64" and jdk_version == 19) # Linux-riscv64 for JDK 19 is special cased
- adoptopenjdk_installed.rc != 0
tags: adoptopenjdk_install
# Api does not return release information for JDK10
block:
- name: Get Signature File Link (Linux/Alpine-Linux)
shell: curl -s 'https://api.adoptium.net/v3/assets/feature_releases/{{ jdk_version }}/ga?architecture={{ api_architecture }}&heap_size=normal&image_type=jdk&jvm_impl={{ bootjdk }}&os={{ platformLinux }}&page=0&page_size=1&project=jdk&vendor=eclipse' | grep signature_link | awk '{split($0,a,"\""); print a[4]}'
shell: curl -s '{{ api_url }}/v3/assets/feature_releases/{{ jdk_version }}/ga?architecture={{ api_architecture }}&heap_size=normal&image_type=jdk&jvm_impl={{ bootjdk }}&os={{ platformLinux }}&page=0&page_size=1&project=jdk&vendor=eclipse' | grep signature_link | awk '{split($0,a,"\""); print a[4]}'
when:
- jdk_version != 10
- not (jdk_version == 8 and ansible_architecture == "s390x")
register: sig_output

- name: Download latest release from api.adoptopenjdk.net (Linux/Alpine-Linux)
- name: Download latest release (Linux/Alpine-Linux)
get_url:
url: https://api.adoptopenjdk.net/v3/binary/latest/{{ jdk_version }}/ga/{{ platformLinux }}/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk
url: {{ api_url }}/v3/binary/latest/{{ jdk_version }}/ga/{{ platformLinux }}/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk
dest: /tmp/jdk{{ jdk_version }}.tar.gz
mode: 0440
retries: 3
delay: 5
register: adopt_download
until: adopt_download is not failed
when: {{ jdk_version }} == 10 or {{ jdk_version }} == 16

- name: Download latest release from api.adoptium.net (Linux/Alpine-Linux)
get_url:
url: https://api.adoptopenjdk.net/v3/binary/latest/{{ jdk_version }}/ga/{{ platformLinux }}/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/eclipse
dest: /tmp/jdk{{ jdk_version }}.tar.gz
mode: 0440
retries: 3
delay: 5
register: adopt_download
until: adopt_download is not failed
when: not ( {{ jdk_version }} == 10 or {{ jdk_version }} == 16 )
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed

- name: GPG Signature verification (Linux/Alpine-Linux)
script: ../Supporting_Scripts/package_signature_verification.sh -f /tmp/jdk{{ jdk_version }}.tar.gz -sl "{{ sig_output.stdout }}" -k {{ key.adoptium }}
Expand All @@ -184,6 +187,36 @@
path: /tmp/jdk{{ jdk_version }}.tar.gz
state: absent

# JDK 19 on Linux-riscv64 is a special-case because JDK 19 is the first version that supports
# RISC-V. There is also no JDK 19 or 20 available on Ubuntu 20.04 that we can use as boot JDK.
- name: Install JDK {{ jdk_version }} on Linux-riscv64
when:
- ansible_architecture == "riscv64" and jdk_version == 19
- adoptopenjdk_installed.rc != 0
tags: adoptopenjdk_install
# Api does not return release information for JDK10
block:
- name: Download jdk{{ jdk_version }} release (Linux-riscv64)
get_url:
url: https://ci.adoptium.net/userContent/riscv/jdk19u-riscv64-20231107.glib227.tar.gz
dest: /tmp/jdk19.tar.gz
mode: 0440
retries: 3
delay: 5
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed

- name: Install latest jdk{{ jdk_version }} release if one not already installed (Linux-riscv64)
unarchive:
src: /tmp/jdk19.tar.gz
dest: /usr/lib/jvm
remote_src: yes

- name: Remove jdk19.tar.gz (Linux-riscv64)
file:
path: /tmp/jdk19.tar.gz
state: absent

# # 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 JDK {{ jdk_version }} release if not already installed (CentOS6)
Expand All @@ -193,16 +226,16 @@
tags: adoptopenjdk_install
block:
- name: Download latest JDK {{ jdk_version }} release (CentOS6)
command: wget -q 'https://api.adoptopenjdk.net/v3/binary/latest/{{ jdk_version }}/ga/{{ platformLinux }}/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk' -O /tmp/jdk{{ jdk_version }}.tar.gz
command: wget -q '{{ api_url }}/v3/binary/latest/{{ jdk_version }}/ga/{{ platformLinux }}/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk' -O /tmp/jdk{{ jdk_version }}.tar.gz
vars:
ansible_python_interpreter: /usr/local/python2/bin/python2.7
retries: 3
delay: 5
register: adopt_download
until: adopt_download is not failed
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed

- name: Get Signature File Link (CentOS6)
shell: curl -s 'https://api.adoptium.net/v3/assets/feature_releases/{{ jdk_version }}/ga?architecture={{ api_architecture }}&heap_size=normal&image_type=jdk&jvm_impl={{ bootjdk }}&os={{ platformLinux }}&page=0&page_size=1&project=jdk&vendor=eclipse' | grep signature_link | awk '{split($0,a,"\""); print a[4]}'
shell: curl -s '{{ api_url }}/v3/assets/feature_releases/{{ jdk_version }}/ga?architecture={{ api_architecture }}&heap_size=normal&image_type=jdk&jvm_impl={{ bootjdk }}&os={{ platformLinux }}&page=0&page_size=1&project=jdk&vendor=eclipse' | grep signature_link | awk '{split($0,a,"\""); print a[4]}'
when:
- jdk_version != 10
register: sig_output
Expand Down Expand Up @@ -231,29 +264,29 @@
block:
- name: Download latest JDK {{ jdk_version }} release (macOS)
get_url:
url: https://api.adoptium.net/v3/installer/latest/{{ jdk_version }}/ga/mac/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/eclipse?project=jdk
url: {{ api_url }}/v3/installer/latest/{{ jdk_version }}/ga/mac/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/eclipse?project=jdk
dest: /tmp/{{ jdk_version }}-installer.pkg
register: adopt_download
until: adopt_download is not failed
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed
when:
- jdk_version != 10

- name: Download JDK10 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
src: {{ api_url }}/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: adopt_download
until: adopt_download is not failed
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed
when:
- jdk_version == 10

- name: Get Signature File Link (macOS)
shell: curl -s 'https://api.adoptium.net/v3/assets/latest/{{ jdk_version }}/{{ bootjdk }}?architecture={{ api_architecture }}&image_type=jdk&os=mac&vendor=eclipse' | grep signature_link | grep pkg | awk '{split($0,a,"\""); print a[4]}'
shell: curl -s '{{ api_url }}/v3/assets/latest/{{ jdk_version }}/{{ bootjdk }}?architecture={{ api_architecture }}&image_type=jdk&os=mac&vendor=eclipse' | grep signature_link | grep pkg | awk '{split($0,a,"\""); print a[4]}'
when:
- jdk_version != 10
register: sig_output
Expand Down Expand Up @@ -291,7 +324,7 @@
group: wheel
become: yes
become_user: root
become_method: sudo
become_method: ansible.builtin.sudo

- name: Install latest JDK {{ jdk_version }} release if one not already installed (Solaris)
when:
Expand All @@ -300,12 +333,12 @@
tags: adoptopenjdk_install
block:
- name: Download latest JDK {{ jdk_version }} release (Solaris)
command: wget https://api.adoptium.net/v3/binary/latest/{{ jdk_version }}/ga/solaris/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/eclipse?project=jdk -O /tmp/jdk-{{ jdk_version }}.tar.gz
register: adopt_download
until: adopt_download is not failed
command: wget {{ api_url }}/v3/binary/latest/{{ jdk_version }}/ga/solaris/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/eclipse?project=jdk -O /tmp/jdk-{{ jdk_version }}.tar.gz
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed

- name: Get Signature File Link (Solaris)
shell: curl -s 'https://api.adoptium.net/v3/assets/latest/{{ jdk_version }}/{{ bootjdk }}?architecture={{ api_architecture }}&image_type=jdk&os=solaris&vendor=eclipse' | grep signature_link | awk '{split($0,a,"\""); print a[4]}'
shell: curl -s '{{ api_url }}/v3/assets/latest/{{ jdk_version }}/{{ bootjdk }}?architecture={{ api_architecture }}&image_type=jdk&os=solaris&vendor=eclipse' | grep signature_link | awk '{split($0,a,"\""); print a[4]}'
register: sig_output

- name: GPG Signature verification (Solaris)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,31 @@
register: java_installed
tags: Java_install

- name: Use adoptium API if release is available at adoptium
set_fact:
api_url: https://api.adoptium.net
when:
- ( jdk_version == 8 || jdk_version == 11 || jdk_version >= 17 )
tags: adoptopenjdk_install

- name: Use adoptopenjdk API if release is not supported by adoptium
set_fact:
api_url: https://api.adoptopenjdk.net
when:
- ! ( jdk_version == 8 || jdk_version == 11 || jdk_version >= 17 )
tags: adoptopenjdk_install

- name: Set API source for old java versions
set_fact: apisource=api.adoptopenjdk.net
when: jdk_version==10

- name: Download Java{{ jdk_version }}
win_get_url:
url: https://api.adoptopenjdk.net/v3/binary/latest/{{ jdk_version }}/ga/windows/x64/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk
url: {{ api_url }}/v3/binary/latest/{{ jdk_version }}/ga/windows/x64/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk
dest: 'C:\temp\jdk-{{ jdk_version }}.zip'
when: not java_installed.stat.exists and jdk_version!=10
tags: Java_install

# Java 10 is the only version we still need to retrieve from adoptopenjdk
- name: Download Java{{ jdk_version }} from adoptopenjdk
win_get_url:
url: https://api.adoptopenjdk.net/v3/binary/latest/{{ jdk_version }}/ga/windows/x64/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk
url: {{ api_url }}/v3/binary/latest/{{ jdk_version }}/ga/windows/x64/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk
dest: 'C:\temp\jdk-{{ jdk_version }}.zip'
when: not java_installed.stat.exists and jdk_version==10
tags: Java_install
Expand Down

0 comments on commit f4644aa

Please sign in to comment.