mirror of
https://bitbucket.org/atlassian/dc-deployments-automation.git
synced 2025-12-14 08:53:07 -06:00
ITPLT-3960 jdk caching
This commit is contained in:
@@ -21,10 +21,91 @@
|
|||||||
tags:
|
tags:
|
||||||
- molecule-idempotence-notest
|
- molecule-idempotence-notest
|
||||||
|
|
||||||
- name: Install Eclipse Temurin JDK
|
# test if jdk_download_completed lock direcory exists
|
||||||
ansible.builtin.yum:
|
- name: Check if jdk_download_completed lock directory exists
|
||||||
name: "temurin-{{ java_major_version }}-jdk"
|
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
|
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
|
- name: Ensure common JDK symlink exists
|
||||||
community.general.alternatives:
|
community.general.alternatives:
|
||||||
|
|||||||
Reference in New Issue
Block a user