--- - name: Linux Package Upgrade hosts: all remote_user: root tasks: - name: "[Debian] Refresh Package Cache if not older that 1h" apt: update_cache: yes cache_valid_time: 3600 become: true when: ansible_os_family == "Debian" - name: "[AlmaLinux] Refresh Package Cache if not older that 1h" dnf: update_cache: yes become: true when: ansible_os_family == "AlmaLinux" - name: "[Debian] Remove Packages that can no longer be downloaded" apt: autoclean: yes become: true when: ansible_os_family == "Debian" - name: "[Debian] Remove packages that are no longer required" apt: autoremove: yes become: true when: ansible_os_family == "Debian" - name: "[AlmaLinux] Remove packages that are no longer required" dnf: autoremove: yes become: true when: ansible_os_family == "AlmaLinux" - name: "[Debian] Upgrade all packages that need an update" apt: upgrade: full become: true when: ansible_os_family == "Debian" - name: "[AlmaLinux] Upgrade all packages that need an update" dnf: name: "*" state: latest become: true when: ansible_os_family == "AlmaLinux" ...