From 4ca89d7641af92819ae772572270674079af76b0 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Sat, 14 Dec 2024 20:33:31 +0100 Subject: [PATCH] fix(base_system): improve the system-wide upgrade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When upgrading packages to their latest version, decide which Ansible module to use based on the ‹pkg_mgr› Ansible fact instead of the distribution. This approach is more robust, and more correct, as the package managers are shared between some of the distributions. Signed-off-by: Matej Focko --- roles/base_system/tasks/upgrade.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/base_system/tasks/upgrade.yml b/roles/base_system/tasks/upgrade.yml index ca5e602..34c8659 100644 --- a/roles/base_system/tasks/upgrade.yml +++ b/roles/base_system/tasks/upgrade.yml @@ -4,16 +4,16 @@ name: "*" state: latest update_cache: true - when: ansible_distribution in [ "Debian", "Ubuntu" ] + when: ansible_facts.pkg_mgr == "apt" - name: Upgrade all packages with ‹dnf› ansible.builtin.dnf: name: "*" state: latest - when: ansible_distribution in [ "AlmaLinux", "CentOS", "Fedora" ] + when: ansible_facts.pkg_mgr == "dnf" - name: Upgrade all packages with ‹zypper› community.general.zypper: name: "*" state: latest - when: "'openSUSE' in ansible_distribution" + when: ansible_facts.pkg_mgr == "zypper"