diff --git a/ansible/playbooks/roles/repository/files/download-requirements/src/command/dnf.py b/ansible/playbooks/roles/repository/files/download-requirements/src/command/dnf.py index eab607cebb..1196237b74 100644 --- a/ansible/playbooks/roles/repository/files/download-requirements/src/command/dnf.py +++ b/ansible/playbooks/roles/repository/files/download-requirements/src/command/dnf.py @@ -27,15 +27,17 @@ class Dnf(DnfBase): def update(self, package: str = None, disablerepo: str = None, enablerepo: str = None, + ignore_already_installed_error: bool = False, releasever: str = None, assume_yes: bool = True): - """ Interface for `dnf update` :param package: :param disablerepo: :param enablerepo: + :param ignore_already_installed_error: if set to True, + `The same or higher version of {package} is already installed` error is ignored :param releasever: :param assume_yes: if set to True, -y flag will be used """ @@ -61,11 +63,18 @@ def update(self, package: str = None, if 'error' in proc.stdout: raise CriticalError( f'Found an error. dnf update failed for package `{package}`, reason: `{proc.stdout}`') - if self._filter_non_critical_errors(proc.stderr): + + filtered_stderr: str = self._filter_non_critical_errors(proc.stderr) + + if filtered_stderr: + if (ignore_already_installed_error + and all(string in filtered_stderr for string in + ('The same or higher version', 'is already installed, cannot update it.'))): + return + raise CriticalError( f'dnf update failed for packages `{package}`, reason: `{proc.stderr}`') - def install(self, package: str, assume_yes: bool = True): """ diff --git a/ansible/playbooks/roles/repository/files/download-requirements/src/mode/red_hat_family_mode.py b/ansible/playbooks/roles/repository/files/download-requirements/src/mode/red_hat_family_mode.py index 99ec3fc692..34d0df11b3 100644 --- a/ansible/playbooks/roles/repository/files/download-requirements/src/mode/red_hat_family_mode.py +++ b/ansible/playbooks/roles/repository/files/download-requirements/src/mode/red_hat_family_mode.py @@ -72,7 +72,8 @@ def _install_base_packages(self): if not epel_package_initially_present: self.__installed_packages.append('epel-release') else: - self._tools.dnf.update('https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm') + self._tools.dnf.update('https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm', + ignore_already_installed_error=True) self.__remove_dnf_cache_for_custom_repos() self._tools.dnf.makecache(timer=True)