Crossposted using Lemmit.

Original post from /r/debian by /u/zoliky on 2023-07-07 15:19:31+00:00.


I attempted this task, which, based on my understanding, should clean the APT cache and remove the files from the /var/cache/apt folder.

- name: System | Post-tasks | Clean APT cache
  become: true
    ansible.builtin.apt:
      clean: true
  when: ansible_facts['distribution'] == "Debian"

Despite the task running successfully, no changes are observed in the /var/cache/apt folder, and the files remain intact.

However, when I execute the task with the command module intead, the cache is successfully cleaned, and there are no files present in the /var/cache/apt directory afterwards.

- name: System | Post-tasks | Clean APT cache
  become: true
    ansible.builtin.command:
      cmd: apt clean
  when: ansible_facts['distribution'] == "Debian"

I’m wondering if there could be a potential bug that prevents the first task from fulfilling its purpose. I’m running Ansible version 2.14.3 on Debian 12. Or it is possible that I may have overlooked a parameter in the task? Any suggestions or recommendations would be greatly appreciated.