ITPLT-3960 really ugly work-around to prevent dnf removing cache files

This commit is contained in:
bmeehan
2024-08-16 22:42:04 +10:00
parent 2a5ded9773
commit 14adb1f168

View File

@@ -39,15 +39,16 @@
# handle the jdk download on only 1 node # handle the jdk download on only 1 node
- block: - block:
- name: Download Eclipse Temurin JDK with dnf - name: Try 5 times to download Eclipse Temurin JDK with dnf
ansible.builtin.dnf: ansible.builtin.dnf:
name: "temurin-{{ java_major_version }}-jdk" name: "temurin-{{ java_major_version }}-jdk"
state: present state: present
download_dir: "{{ atl_product_home_shared_download_dir }}" download_dir: "{{ atl_product_home_shared_download_dir }}"
download_only: yes download_only: true
update_cache: true
register: jdk_downloaded register: jdk_downloaded
retries: 5 retries: 5
delay: 30 delay: 10
until: jdk_downloaded is succeeded until: jdk_downloaded is succeeded
- name: Create jdk_download_completed lock directory if download was successful - name: Create jdk_download_completed lock directory if download was successful
@@ -61,18 +62,19 @@
path: "{{ atl_product_home_shared_download_dir }}/temurin-{{ java_major_version }}-jdk_downloading" path: "{{ atl_product_home_shared_download_dir }}/temurin-{{ java_major_version }}-jdk_downloading"
state: absent state: absent
# this when applies to the whole block - only do this block on the one node that created the downloading lock
when: when:
- jdk_downloading_lock - jdk_downloading_lock
- jdk_downloading_lock.changed - jdk_downloading_lock.changed
# all nodes can wait here in race condition until the completed lock is present # all nodes can wait here in race condition briefly for dl to complete and the downloaded_lock to exist
- name: try waiting for jdk_download_completed lock to exist - name: wait and test 5 times for jdk_download_completed lock to exist
ansible.builtin.wait_for: ansible.builtin.wait_for:
path: "{{ atl_product_home_shared_download_dir }}/temurin-{{ java_major_version }}-jdk_download_completed" path: "{{ atl_product_home_shared_download_dir }}/temurin-{{ java_major_version }}-jdk_download_completed"
state: present state: present
timeout: 10 timeout: 10
ignore_errors: true ignore_errors: true
register: jdk_download_completed register: jdk_download_completed_lock
retries: 5 retries: 5
# as long as we have a valid rpm filepath do the copy/install block # as long as we have a valid rpm filepath do the copy/install block
@@ -86,31 +88,24 @@
size: 1 size: 1
register: temurin_rpm_file register: temurin_rpm_file
- name: set fact of the basename of the temurin file - name: set facts for the path and the basename of the temurin file
ansible.builtin.set_fact: ansible.builtin.set_fact:
temurin_src_path: "{{ item.path }}" temurin_src_path: "{{ item.path }}"
temurin_file_name: "{{ item.path | basename }}" temurin_file_name: "{{ item.path | basename }}"
loop: "{{ temurin_rpm_file.files | flatten }}" loop: "{{ temurin_rpm_file.files | flatten }}"
- name: Copy temurin_rpm_file to /tmp because dnf module removes the cached rpm - name: Install JDK from cache copy of the rpm file - keepcache
ansible.builtin.copy: ansible.builtin.command:
src: "{{ temurin_src_path }}" cmd: "dnf -y install {{ temurin_file_name }} --setopt=installonly_limit=3 --setopt=keepcache=1"
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 register: dnf_installed
when: when:
- jdk_download_completed.state is defined - jdk_download_completed_lock.state is defined
- temurin_rpm_file.files is defined - jdk_download_completed_lock.state == "directory"
- temurin_rpm_file.files | length > 0
- name: Ensure Eclipse Temurin JDK is present (get from internet if cache install fails or is unavailable) - name: Ensure Eclipse Temurin JDK is present (get from internet if cache install fails or is unavailable)
ansible.builtin.dnf: ansible.builtin.command:
name: "temurin-{{ java_major_version }}-jdk" cmd: "dnf -y install temurin-{{ java_major_version }}-jdk --setopt=installonly_limit=3 --setopt=keepcache=1"
state: present
- name: Ensure common JDK symlink exists - name: Ensure common JDK symlink exists
community.general.alternatives: community.general.alternatives: