---
- name: Linux Package Upgrade
  hosts: all
  remote_user: root
  tasks:
    - name: Refresh Package Cache if not older that 1h
      apt:
        update_cache: yes
        cache_valid_time: 3600
      become: true

    - name: Remove Packages that can no longer be downloaded
      apt:
        autoclean: yes
      become: true

    - name: Remove packages that are no longer required
      apt:
        autoremove: yes
      become: true

    - name: Upgrade all packages that need an update
      apt:
        upgrade: full
      become: true
...        

