--- /dev/null
+#! /bin/sh
+
+LC_CTYPE=en_US.UTF-8 hosts="`\"$HOME\"/.virtualenvs/ansible/bin/ansible --list-hosts servers | tail -n +2`"
+
+echo localhost
+sudo apt-get clean
+sudo find /var/lib/apt/lists -maxdepth 1 -type f \! -name lock -delete
+
+for host in $hosts; do
+ echo $host
+ ssh $host "sudo apt-get clean; exec sudo find /var/lib/apt/lists
+ -maxdepth 1 -type f \! -name lock -delete"
+done
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 }}"
+ - name: Remove apt files
+ command: find /var/lib/apt/lists -maxdepth 1 -type f ! -name lock -delete