Skip to content

Commit

Permalink
ansible: install temurin JDK on macOS (#3085)
Browse files Browse the repository at this point in the history
Refs: #3030
  • Loading branch information
targos authored Nov 23, 2022
1 parent fc1e269 commit 8623555
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 27 deletions.
23 changes: 2 additions & 21 deletions ansible/roles/java-base/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,32 +51,13 @@
# Package manager mapping in ansible/roles/package-upgrade/vars/main.yml.
use: "{{ os|match_key(pm)|default(omit) }}"

- name: install java tap (macOS)
become_user: administrator
when: java.rc > 0 and os|startswith("macos") and arch == "x64"
homebrew_tap:
name: AdoptOpenJDK/openjdk
state: present

- name: install java (macOS)
become_user: administrator
when: java.rc > 0 and os|startswith("macos") and arch == "x64"
become_user: "{{ ansible_user }}"
when: java.rc > 0 and os|startswith("macos")
homebrew_cask:
name: "{{ java_package_name }}"
state: present

- name: Fetch java (Apple Silicon)
when: java.rc > 0 and os|startswith("macos11") and arch == "arm64"
shell:
chdir: "/Users/{{ ansible_user }}"
cmd: "curl -L -o zulu8.52.0.23-ca-jdk8.0.282-macosx_aarch64.tar.gz https://cdn.azul.com/zulu/bin/zulu8.52.0.23-ca-jdk8.0.282-macosx_aarch64.tar.gz"

- name: Extract java (Apple Silicon)
when: java.rc > 0 and os|startswith("macos11") and arch == "arm64"
shell:
chdir: "/Users/{{ ansible_user }}"
cmd: "tar -xf zulu8.52.0.23-ca-jdk8.0.282-macosx_aarch64.tar.gz"

- name: install webupd8 oracle java 8 extras
when: java.rc > 0 and os == "ubuntu1404" and arch != "ppc64"
package: name="{{item}}" state=present
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/java-base/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ packages: {
'fedora32': 'java-11-openjdk-headless',
'freebsd': 'openjdk11-jre',
'ibmi': 'openjdk-11-ea',
'macos': 'adoptopenjdk8',
'macos': 'temurin17',
'rhel7': 'java-11-openjdk',
'rhel8': 'java-17-openjdk',
'smartos': 'openjdk8',
Expand Down
3 changes: 1 addition & 2 deletions ansible/roles/jenkins-worker/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ java_path: {
'macos10.14': 'java',
'macos10.15': 'java',
'macos11': 'java',
# Currently hardcoded untill adopt have their build available
'macos11.0': '/Users/{{ ansible_user }}/zulu8.52.0.23-ca-jdk8.0.282-macosx_aarch64/bin/java',
'macos11.0': 'java',
'smartos15': '/opt/local/java/openjdk8/bin/java',
'smartos16': '/opt/local/java/openjdk8/bin/java',
'smartos17': '/opt/local/java/openjdk8/bin/java',
Expand Down
7 changes: 4 additions & 3 deletions ansible/roles/package-upgrade/tasks/partials/brew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
raw: xcode-select --print-path &> /dev/null
register: xcode
ignore_errors: yes
check_mode: no

- name: Install xcode-tools
script: files/install-xcode.sh
when: xcode.rc > 1

- name: Check if Homebrew is already installed (Apple Sillicon)
- name: Check if Homebrew is already installed (Apple Silicon)
stat:
path: /opt/homebrew/bin/brew
register: armbrew
Expand Down Expand Up @@ -45,10 +46,10 @@
homebrew_tap:
name: buo/cask-upgrade

- name: Add AdoptOpenJDK Java Repo
- name: Install brew cask-versions
become_user: "{{ ansible_user }}"
homebrew_tap:
name: AdoptOpenJDK/openjdk
name: homebrew/cask-versions

- name: Update Casks
become_user: "{{ ansible_user }}"
Expand Down

0 comments on commit 8623555

Please sign in to comment.