]> git.phdru.name Git - ansible.git/commitdiff
Feat(debian): Add `clean-apt` playbook
authorOleg Broytman <phd@phdru.name>
Sun, 28 Dec 2025 16:17:25 +0000 (19:17 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 28 Dec 2025 23:40:11 +0000 (02:40 +0300)
playbooks/debian/clean-apt.yaml [new file with mode: 0644]

diff --git a/playbooks/debian/clean-apt.yaml b/playbooks/debian/clean-apt.yaml
new file mode 100644 (file)
index 0000000..8e80033
--- /dev/null
@@ -0,0 +1,23 @@
+- name: Update Debian systems with apt
+  hosts: "{{ hosts | default('all') }}"
+  become: yes
+  gather_facts: false
+  tasks:
+    - name: Clean apt
+      apt:
+        clean: true
+
+    - name: Find apt files
+      find:
+        paths: /var/lib/apt/lists
+        patterns: '*'
+        excludes: lock
+        depth: 1
+      register: apt_list
+    - name: Clean apt files
+      file:
+        path: "{{ item.path }}"
+        state: absent
+      with_items: "{{ apt_list.files }}"
+      loop_control:
+        label: "{{ item.path }}"