fix(base_system): improve the system-wide upgrade

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 <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-12-14 20:33:31 +01:00
parent a79bfb5551
commit 4ca89d7641
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8

View file

@ -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"