--- - name: Add Adoptium repo and install Eclipse Temurin JDK if necessary on Amazon Linux 2023 block: # There is no amazonlinux/2023 package available from the Adoptium repo; AL2023 docs point to upstream compatiblity # with Fedora 34, 35, and 36, so we use the latest of those for the Temurin package for now - name: Add Adoptium yum repository ansible.builtin.yum_repository: name: Adoptium file: adoptium description: Adoptium Repo baseurl: - "https://packages.adoptium.net/artifactory/rpm/fedora/36/{{ ansible_architecture }}" - "{{ atl_adoptium_alternate_url is defined | ternary(atl_adoptium_alternate_url, '') }}" gpgkey: - https://packages.adoptium.net/artifactory/api/gpg/key/public - "{{ atl_adoptium_gpgkey_alternate_url is defined | ternary(atl_adoptium_gpgkey_alternate_url, '') }}" gpgcheck: yes state: present tags: - molecule-idempotence-notest # test if jdk_download_completed lock direcory exists - name: Check if jdk_download_completed lock directory exists ansible.builtin.stat: path: "{{ atl_product_home_shared_download_dir }}/temurin-{{ java_major_version }}-jdk_download_completed" register: jdk_download_completed_lock - name: take out jdk_downloading lock directory ansible.builtin.file: path: "{{ atl_product_home_shared_download_dir }}/temurin-{{ java_major_version }}-jdk_downloading" state: directory register: jdk_downloading_lock when: - jdk_download_completed_lock - not jdk_download_completed_lock.stat.exists # handle the jdk download on only 1 node - block: - name: Download Eclipse Temurin JDK with yum ansible.builtin.yum: name: "temurin-{{ java_major_version }}-jdk" state: latest download_dir: "{{atl_product_home_shared_download_dir}}" download_only: yes register: jdk_downloaded retries: 5 delay: 30 until: jdk_downloaded is succeeded - name: Create jdk_download_completed lock directory if download was successful ansible.builtin.file: path: "{{ atl_product_home_shared_download_dir }}/temurin-{{ java_major_version }}-jdk_download_completed" state: directory when: jdk_downloaded.changed - name: Remove jdk_downloading lock directory if we took out succeeded lock ansible.builtin.file: path: "{{ atl_product_home_shared_download_dir }}/temurin-{{ java_major_version }}-jdk_downloading" state: absent when: jdk_downloaded.changed when: - jdk_downloading_lock - jdk_downloading_lock.changed # all nodes can wait here in race condition until the completed lock is present - name: Wait for jdk_download_completed lock to exist ansible.builtin.wait_for: path: "{{ atl_product_home_shared_download_dir }}/temurin-{{ java_major_version }}-jdk_download_completed" state: present delay: 30 failed_when: false register: jdk_download_completed retries: 5 - name: Find a file called temurin* in atl_product_home_shared_download_dir ansible.builtin.find: paths: "{{ atl_product_home_shared_download_dir }}" patterns: "temurin-{{ java_major_version }}-*.rpm" file_type: file recurse: no size: 1 register: temurin_rpm_file # as long as we have a valid rpm filepath do the copy/install block - block: - name: set fact of the basename of the temurin file ansible.builtin.set_fact: temurin_src_path: "{{ item.path }}" temurin_file_name: "{{ item.path |basename }}" loop: "{{ temurin_rpm_file.files | flatten }}" - name: Copy temurin_rpm_file to /tmp because dnf module removes the cached rpm ansible.builtin.copy: src: "{{ temurin_src_path }}" dest: "/tmp/{{ temurin_file_name }}" - name: Install JDK from /tmp copy of the rpm file ansible.builtin.dnf: name: "/tmp/{{ temurin_file_name }}" state: present register: dnf_installed when: - jdk_download_completed.state == "directory" - temurin_rpm_file.files - temurin_rpm_file.files | length > 0 - name: Ensure common JDK symlink exists community.general.alternatives: link: "/usr/lib/jvm/java" name: "java_sdk" path: "/usr/lib/jvm/temurin-{{ java_major_version }}-jdk" priority: 99 when: atl_use_system_jdk | bool tags: - runtime_pkg - name: Install other base packages on Amazon Linux 2023 ansible.builtin.dnf: name: - dejavu-fonts-all # Required by the installer