apt autoclean/autoremove not working?

Hii

On my Debian (11) systems I end up having many deb files in /var/cache/apt/archives, and I’m trying to get the apt module to clean those up at the end of a playbook.
But I can’t get this to work using the documented options. None of the below tasks removes the files:

  • name: Removed unused package from the cache
    apt:
    autoclean: yes

  • name: Remove dependencies that are no longer required
    apt:
    autoremove: yes

I have added update_cache to them, but also to no avail.
Any ideas?

Using

command: apt-get clean

does what I want, but that feels like throwing in the towel…

OK, I incorrectly assumed ‘autoclean’ is the same as ‘clean’.
The latter is not supported: https://github.com/ansible/ansible/issues/38920
I’ll use the ‘command’ workaround for now.

thx