From c80783261015955c6ef9f0c54f4b1386dcead984 Mon Sep 17 00:00:00 2001 From: to-bar <46519524+to-bar@users.noreply.github.com> Date: Thu, 25 Feb 2021 09:50:57 +0100 Subject: [PATCH] Fix task "repository : Wait for yum lock to be released" for CentOS Minimal (#2078) * Bypass rhui-update-client on Azure * Do not use yum module waiting for yum lock to be released * Update changelog --- CHANGELOG-0.9.md | 1 + .../roles/repository/tasks/RedHat/setup.yml | 26 +++++++++++++++---- .../roles/repository/tasks/teardown.yml | 17 ++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/CHANGELOG-0.9.md b/CHANGELOG-0.9.md index 46d33121fd..7de4dd7a5d 100644 --- a/CHANGELOG-0.9.md +++ b/CHANGELOG-0.9.md @@ -13,6 +13,7 @@ - [#2166](https://github.com/epiphany-platform/epiphany/issues/2166) - Replace Bintray repository - [#2012](https://github.com/epiphany-platform/epiphany/issues/2012) - Patch cgroup drivers (switch to systemd) - [#1824](https://github.com/epiphany-platform/epiphany/issues/1824) - offline installation fails with error 'yum lockfile is held by another process' (Azure/RHEL) +- [#2067](https://github.com/epiphany-platform/epiphany/issues/2067) - [CentOS] epicli fails on task "repository : Wait for yum lock to be released" on CentOS Minimal ## [0.9.0] 2021-01-19 diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/RedHat/setup.yml b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/RedHat/setup.yml index 49c44dbb92..0359c34031 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/RedHat/setup.yml +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/RedHat/setup.yml @@ -1,9 +1,25 @@ --- -- name: Wait for yum lock to be released - yum: - list: installed - module_defaults: - yum: { lock_timeout: "{{ yum_lock_timeout }}" } +# Bypass yum run by /etc/cron.daily/rhui-update-client on Azure to avoid error 'yum lockfile is held by another process' +- name: Bypass /etc/cron.daily/rhui-update-client + when: specification.provider in ['azure', 'any'] # any for AzBI module + block: + - name: Check if /etc/cron.daily/rhui-update-client file exists + stat: + path: /etc/cron.daily/rhui-update-client + get_attributes: false + get_checksum: false + get_mime: false + register: stat_rhui_update_client_to_bypass + + - name: Bypass /etc/cron.daily/rhui-update-client by moving to temporary location # it's restored in teardown + command: mv /etc/cron.daily/rhui-update-client /var/tmp/rhui-update-client + when: stat_rhui_update_client_to_bypass.stat.exists + +- name: Wait for yum lock to be released # do not use 'yum' module with 'list' here since it requires yum-utils package + wait_for: + path: /var/run/yum.pid + state: absent + timeout: "{{ yum_lock_timeout }}" - name: Set SELinux in permissive mode until the machine is rebooted command: setenforce 0 diff --git a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown.yml b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown.yml index b1821a4773..9a6433e367 100644 --- a/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown.yml +++ b/core/src/epicli/data/common/ansible/playbooks/roles/repository/tasks/teardown.yml @@ -8,6 +8,23 @@ - name: Disable epirepo shell: /tmp/epi-repository-setup-scripts/disable-epirepo-client.sh +- name: Restore /etc/cron.daily/rhui-update-client + when: + - ansible_os_family == "RedHat" + - specification.provider in ['azure', 'any'] # any for AzBI module + block: + - name: Check if /var/tmp/rhui-update-client file exists + stat: + path: /var/tmp/rhui-update-client + get_attributes: false + get_checksum: false + get_mime: false + register: stat_rhui_update_client_to_restore + + - name: Restore /etc/cron.daily/rhui-update-client + command: /var/tmp/rhui-update-client mv /etc/cron.daily/rhui-update-client + when: stat_rhui_update_client_to_restore.stat.exists + - name: Remove epirepo packages directory file: state: absent