---
- name: Update Debian-based systems
  hosts: debian_clients
  become: yes
  vars:
    ansible_become_method: sudo

  tasks:
    - name: Update package cache
      apt:
        update_cache: yes
        cache_valid_time: 3600

    - name: Upgrade all packages
      apt:
        upgrade: full
        autoclean: yes
        autoremove: yes

    - name: Check for available updates
      command: apt list --upgradable
      register: apt_updates
      changed_when: false
      check_mode: no

    - name: Show available updates
      debug:
        var: apt_updates.stdout_lines
