From d3a52f108d91ae7fd1bc227d7fb7f4eb19a329d1 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Mon, 14 Oct 2019 18:08:16 +0100 Subject: [PATCH] configure-mirrors: Consolidate dnf/yum handler Simplify logic by using a single handler for redhat systems. Change-Id: I328f0abb602f0d71372812ff64d8ad3f3764fbd0 --- roles/configure-mirrors/handlers/main.yaml | 16 ++++++---------- roles/configure-mirrors/tasks/main.yaml | 5 +++++ .../configure-mirrors/tasks/mirror/CentOS-7.yaml | 2 +- .../configure-mirrors/tasks/mirror/CentOS-8.yaml | 2 +- roles/configure-mirrors/tasks/mirror/Fedora.yaml | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/roles/configure-mirrors/handlers/main.yaml b/roles/configure-mirrors/handlers/main.yaml index 97aaf7620..560ad787c 100644 --- a/roles/configure-mirrors/handlers/main.yaml +++ b/roles/configure-mirrors/handlers/main.yaml @@ -7,19 +7,15 @@ tags: - skip_ansible_lint -- name: Update dnf cache +- name: Update yum/dnf cache become: yes command: "{{ item }}" + args: + warn: false with_items: - - dnf clean all - - dnf makecache - -- name: Update yum cache - become: yes - command: "{{ item }}" - with_items: - - yum clean all - - yum makecache + - "{{ ansible_pkg_mgr }} clean all" + - "{{ ansible_pkg_mgr }} makecache -v" + # verbose is needed in order to make it possible to debug potential failures - name: Update zypper cache become: yes diff --git a/roles/configure-mirrors/tasks/main.yaml b/roles/configure-mirrors/tasks/main.yaml index 4f65d42b6..c98c53dc7 100644 --- a/roles/configure-mirrors/tasks/main.yaml +++ b/roles/configure-mirrors/tasks/main.yaml @@ -1,3 +1,8 @@ +- name: gather needed facts + when: ansible_pkg_mgr is not defined + setup: + gather_subset: pkg_mgr + - name: Set up infrastructure mirrors include: mirror.yaml when: mirror_fqdn is defined diff --git a/roles/configure-mirrors/tasks/mirror/CentOS-7.yaml b/roles/configure-mirrors/tasks/mirror/CentOS-7.yaml index 38847e92e..799147cf8 100644 --- a/roles/configure-mirrors/tasks/mirror/CentOS-7.yaml +++ b/roles/configure-mirrors/tasks/mirror/CentOS-7.yaml @@ -10,7 +10,7 @@ - etc/yum.repos.d/CentOS-Base.repo - etc/yum.repos.d/epel.repo notify: - - Update yum cache + - Update yum/dnf cache # http://dnf.readthedocs.io/en/latest/conf_ref.html#options-for-both-main-and-repo # deltarpm is useful when the bottleneck is the network throughput. diff --git a/roles/configure-mirrors/tasks/mirror/CentOS-8.yaml b/roles/configure-mirrors/tasks/mirror/CentOS-8.yaml index 8e6489789..b42826f40 100644 --- a/roles/configure-mirrors/tasks/mirror/CentOS-8.yaml +++ b/roles/configure-mirrors/tasks/mirror/CentOS-8.yaml @@ -13,7 +13,7 @@ - etc/yum.repos.d/CentOS-PowerTools.repo - etc/yum.repos.d/epel.repo notify: - - Update dnf cache + - Update yum/dnf cache # http://dnf.readthedocs.io/en/latest/conf_ref.html#options-for-both-main-and-repo # deltarpm is useful when the bottleneck is the network throughput. diff --git a/roles/configure-mirrors/tasks/mirror/Fedora.yaml b/roles/configure-mirrors/tasks/mirror/Fedora.yaml index fcf664646..81eb5f460 100644 --- a/roles/configure-mirrors/tasks/mirror/Fedora.yaml +++ b/roles/configure-mirrors/tasks/mirror/Fedora.yaml @@ -10,7 +10,7 @@ - etc/yum.repos.d/fedora.repo - etc/yum.repos.d/fedora-updates.repo notify: - - Update dnf cache + - Update yum/dnf cache # http://dnf.readthedocs.io/en/latest/conf_ref.html#options-for-both-main-and-repo # deltarpm is useful when the bottleneck is the network throughput.