Skip to content

Commit

Permalink
Update installed JDKs to match current boot JDK requirements (adoptiu…
Browse files Browse the repository at this point in the history
…m#3073)

* unixPB aixPB winPB: Update boot JDKs to match current requirements

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* Download JDK10 for windows from api.adoptopenjdk.net

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* unixPB: Update role to pull JDKs from api.adoptium for current releases

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* Use correct API for each JDK version

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* variable expansions at start of expression must be quoted

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* Fix OR conditional

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* fix conditional

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* syntax fixup

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* Final fixups, plus inclusing JDK21 where possible

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* Updates following linter failures

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* Fixups - testing

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* Fix AIX

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* Sort Windows

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* Solaris, riscv64 and CentO6 fixup

Signed-off-by: Stewart X Addison <sxa@redhat.com>

* Update ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml

Removing double space

* Update ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml

Lining up comment hashes.

* Update ansible/playbooks/AdoptOpenJDK_Unix_Playbook/roles/adoptopenjdk_install/tasks/main.yml

Lining up comment hashes.

---------

Signed-off-by: Stewart X Addison <sxa@redhat.com>
Co-authored-by: Adam Farley <adfarley@redhat.com>
  • Loading branch information
sxa and adamfarley authored Mar 11, 2024
1 parent 5163c57 commit 86510da
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- '11'
- '16'
- '17'
- '21'

- name: Set /usr/java8_64 as default
file:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,65 @@
os_img: "aix/ppc64/jdk"
heap: "normal"
impl: "hotspot"
new_baseurl: "https://api.adoptium.net/v3/binary/latest"
new_vendor: "eclipse"
baseurl: "https://api.adoptopenjdk.net/v3/binary/latest"
vendor: "adoptopenjdk"
project: "{{ heap }}/{{ vendor }}?project=jdk"
adoptium_baseurl: "https://api.adoptium.net/v3/binary/latest"
adoptopenjdk_baseurl: "https://api.adoptopenjdk.net/v3/binary/latest"
adoptium_project: "{{ heap }}/eclipse?project=jdk"
adoptopenjdk_project: "{{ heap }}/adoptopenjdk?project=jdk"
block:
- name: Verify space in /usr
include_tasks: chfs.yml

- name: Check for jdk {{ jdk }} availability
- name: Check for jdk {{ jdk }} availability in /usr/java{{ jdk }}_64
stat:
path: /usr/java{{ jdk }}_64
path: /usr/java{{ jdk }}_64/bin/java
register: java_installed

- name: Download JDK {{ jdk }} binary
- name: Download JDK {{ jdk }} binary from api.adoptopenjdk.net
get_url:
url: "{{ baseurl }}/{{ jdk }}/ga/{{ os_img }}/{{ impl }}/{{ project }}"
url: "{{ adoptopenjdk_baseurl }}/{{ jdk }}/ga/{{ os_img }}/{{ impl }}/{{ adoptopenjdk_project }}"
dest: /tmp/jdk{{ jdk }}.tar.gz
mode: 0440
timeout: 25
retries: 3
delay: 5
when:
- java_installed.stat.isdir is not defined
- not java_installed.stat.exists
- jdk == '10' or jdk == '16' # These are the only two we still use from adoptopenjdk API
register: openjdk

- name: Download JDK {{ jdk }} binary from api.adoptium.net
get_url:
url: "{{ adoptium_baseurl }}/{{ jdk }}/ga/{{ os_img }}/{{ impl }}/{{ adoptium_project }}"
dest: /tmp/jdk{{ jdk }}.tar.gz
mode: 0440
timeout: 25
retries: 3
delay: 5
when:
- not java_installed.stat.exists
- not ( jdk == '10' or jdk == '16' )
register: openjdk

- name: Get Signature File Link
shell: curl -s 'https://api.adoptium.net/v3/assets/latest/{{ jdk }}/hotspot?architecture=ppc64&image_type=jdk&os=aix&vendor=eclipse' | grep signature_link | awk '{split($0,a,"\""); print a[4]}'
when:
- jdk != '10' and jdk != '16'
- java_installed.stat.isdir is not defined
- not java_installed.stat.exists
register: sig_output

- name: GPG Signature verification
script: ../Supporting_Scripts/package_signature_verification.sh -f /tmp/jdk{{ jdk }}.tar.gz -sl "{{ sig_output.stdout }}" -k {{ key.adoptium }}
when:
- jdk != '10' and jdk != '16'
- java_installed.stat.isdir is not defined
- not java_installed.stat.exists

- name: Install JDK {{ jdk }} binary
unarchive:
src: /tmp/jdk{{ jdk }}.tar.gz
dest: /usr
remote_src: yes
when:
- java_installed.stat.isdir is not defined
- not java_installed.stat.exists

- name: Report HTTP 404 message
debug:
Expand All @@ -66,7 +79,7 @@
path: /tmp/jdk{{ jdk }}.tar.gz
state: absent
when:
- java_installed.stat.isdir is not defined
- not java_installed.stat.exists

# jdk8 directories do not have a hyphen
- name: Find java 8 directory
Expand All @@ -75,7 +88,7 @@
paths: /usr
patterns: 'jdk8u*'
when:
- java_installed.stat.isdir is not defined
- not java_installed.stat.exists
- jdk == '8'
register: java8_directory

Expand All @@ -85,7 +98,7 @@
paths: /usr
patterns: 'jdk-{{ jdk }}*'
when:
- java_installed.stat.isdir is not defined
- not java_installed.stat.exists
- jdk != '8'
register: java_directory

Expand All @@ -98,7 +111,7 @@
with_items:
- "{{ java8_directory.files }}"
when:
- java_installed.stat.isdir is not defined
- not java_installed.stat.exists
- jdk == '8'

- name: Symlink to java{{ jdk }}_64
Expand All @@ -109,7 +122,7 @@
with_items:
- "{{ java_directory.files }}"
when:
- java_installed.stat.isdir is not defined
- not java_installed.stat.exists
- jdk != '8'
# Defaults for BootJDK API
# AdoptOpenJDK changes to Adoptium:
Expand Down
13 changes: 4 additions & 9 deletions ansible/playbooks/AdoptOpenJDK_Unix_Playbook/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,18 @@
when:
- ansible_distribution != "Solaris"
tags: build_tools
- role: adoptopenjdk_install # JDK19 Build Bootstrap
jdk_version: 18
- 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 # JDK20 Build Bootstrap
jdk_version: 19
when:
- ansible_distribution != "Alpine"
- ansible_distribution != "Solaris"
tags: build_tools
- role: adoptopenjdk_install # Current LTS
jdk_version: 21
when:
- ansible_architecture == "riscv64"
- ansible_distribution != "Solaris"
- 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,28 @@
---
##############################################################
# 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
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: https://api.adoptopenjdk.net
api_vendor: adoptopenjdk
when:
- jdk_version == 10 or jdk_version == 16
tags: adoptopenjdk_install

- name: Set path variable when jdk_version == 8
set_fact:
path: /usr/lib/jvm/jdk8
Expand Down Expand Up @@ -134,21 +150,21 @@
- 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 == 21 or jdk_version == 19 or jdk_version == 17 or jdk_version == 11)) # Linux-riscv64 for JDK 11, 17, 19, 21 are special cased
- not (ansible_architecture == "riscv64" and (jdk_version == 21 or jdk_version == 20 or jdk_version == 19 or jdk_version == 17 or jdk_version == 11)) # Linux-riscv64 for JDK 11, 17, 19, 21 are 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={{ api_vendor }}' | grep signature_link | awk '{split($0,a,"\""); print a[4]}'
when:
- jdk_version != 10
- jdk_version != 10 and jdk_version != 16
- not (jdk_version == 8 and ansible_architecture == "s390x")
register: sig_output

- 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/{{ api_vendor }}?project=jdk"
dest: /tmp/jdk{{ jdk_version }}.tar.gz
mode: 0440
retries: 3
Expand All @@ -159,10 +175,10 @@
- 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 }}
when:
- jdk_version != 10
- jdk_version != 10 and jdk_version != 16
- not (jdk_version == 8 and ansible_architecture == "s390x")

- name: Install latest release if one not already installed (Linux/Alpine-Linux)
- name: Install latest Adopt JDK{{ jdk_version }} if one not already installed (Linux/Alpine-Linux)
unarchive:
src: /tmp/jdk{{ jdk_version }}.tar.gz
dest: /usr/lib/jvm
Expand Down Expand Up @@ -305,7 +321,7 @@
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/{{ api_vendor }}?project=jdk' -O /tmp/jdk{{ jdk_version }}.tar.gz
vars:
ansible_python_interpreter: /usr/local/python2/bin/python2.7
retries: 3
Expand All @@ -314,15 +330,15 @@
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={{ api_vendor }}' | grep signature_link | awk '{split($0,a,"\""); print a[4]}'
when:
- jdk_version != 10
- jdk_version != 10 and jdk_version != 16
register: sig_output

- name: GPG Signature verification (CentOS6)
script: ../Supporting_Scripts/package_signature_verification.sh -f /tmp/jdk{{ jdk_version }}.tar.gz -sl "{{ sig_output.stdout }}" -k {{ key.adoptium }}
when:
- jdk_version != 10
- jdk_version != 10 and jdk_version != 16

- name: Install latest JDK {{ jdk_version }} release (CentOS6)
unarchive:
Expand All @@ -343,16 +359,16 @@
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/{{ api_vendor }}?project=jdk"
dest: /tmp/{{ jdk_version }}-installer.pkg
register: adoptopenjdk_download
until: adoptopenjdk_download is not failed
when:
- jdk_version != 10
- jdk_version != 10 and jdk_version != 16

- 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/{{ api_vendor }}?project=jdk"
remote_src: yes
dest: /Library/Java/JavaVirtualMachines/
become: yes
Expand All @@ -365,20 +381,20 @@
- 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={{ api_vendor }}' | grep signature_link | grep pkg | awk '{split($0,a,"\""); print a[4]}'
when:
- jdk_version != 10
- jdk_version != 10 and jdk_version != 16
register: sig_output

- name: GPG Signature verification (macOS)
script: ../Supporting_Scripts/package_signature_verification.sh -f /tmp/{{ jdk_version }}-installer.pkg -sl "{{ sig_output.stdout }}" -k {{ key.adoptium }}
when:
- jdk_version != 10
- jdk_version != 10 and jdk_version != 16

- name: Run installer for JDK {{ jdk_version }} (macOS)
shell: sudo installer -pkg /tmp/{{ jdk_version }}-installer.pkg -target /
when:
- jdk_version != 10
- jdk_version != 10 and jdk_version != 16

# The boot JDK will be installed into a temurin directory. Playbooks, build and (possibly) test scripts will look for an adoptopenjdk directory
# https://github.com/adoptium/infrastructure/issues/2281#issuecomment-1059322275
Expand Down Expand Up @@ -412,12 +428,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
command: wget {{ api_url }}/v3/binary/latest/{{ jdk_version }}/ga/solaris/{{ api_architecture }}/jdk/{{ bootjdk }}/normal/{{ api_vendor }}?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={{ api_vendor }}' | grep signature_link | awk '{split($0,a,"\""); print a[4]}'
register: sig_output

- name: GPG Signature verification (Solaris)
Expand Down
10 changes: 6 additions & 4 deletions ansible/playbooks/AdoptOpenJDK_Windows_Playbook/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@
jdk_version: 10
- role: Java_install # For Gradle
jdk_version: 11
- role: Java_install # JDK16 build bootstrap
jdk_version: 15
- role: Java_install # JDK17 build bootstrap
- role: Java_install # Latest LTS, for use by agents
jdk_version: 16
- role: Java_install
- role: Java_install # Latest LTS, for use by agents
jdk_version: 17
- role: Java_install # Bootstrap for JDK21
jdk_version: 20
- role: Java_install # Latest LTS, for use by agents
jdk_version: 21
- ANT # Testing
- role: MSVS_2013
when: ansible_architecture == "64-bit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,25 @@
register: java_installed
tags: Java_install

- name: Download Java{{ jdk_version }}
- 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.adoptopenjdk.net/v3/binary/latest/{{ jdk_version }}/ga/windows/x64/jdk/{{ bootjdk }}/normal/adoptopenjdk?project=jdk
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
Expand Down

0 comments on commit 86510da

Please sign in to comment.