--- /dev/null
+- name: List ~{{ user }}/.cache/pip before
+ become: "{{ become | default('false') }}"
+ shell: "du -sh ~{{ user }}/.cache/pip | cut -f1"
+ register: before
+ changed_when: false
+
+- name: Remove old files from ~{{ user }}/.cache/pip
+ become: "{{ become | default('false') }}"
+ shell: "exec find ~{{ user }}/.cache/pip -type f -mtime +{{ days | default('180') }} -delete"
+
+- name: List ~{{ user }}/.cache/pip after
+ become: "{{ become | default('false') }}"
+ shell: "du -sh ~{{ user }}/.cache/pip | cut -f1"
+ register: after
+ changed_when: false
+
+- name: Remove empty directories from ~{{ user }}/.cache/pip
+ become: "{{ become | default('false') }}"
+ shell: "exec find ~{{ user }}/.cache/pip -type d -empty -delete"
--- /dev/null
+- name: Check ~phd/.cache/pip
+ stat:
+ path: ~phd/.cache/pip
+ register: user_cache_exists
+ changed_when: false
+
+- name: Check ~root/.cache/pip
+ become: true
+ stat:
+ path: ~root/.cache/pip
+ register: root_cache_exists
+ changed_when: false
+
+- name: Cleanup ~phd/.cache/pip
+ import_tasks: cleanup-user.yml
+ vars:
+ user: phd
+ when: user_cache_exists.stat.exists
+
+- name: Cleanup ~root/.cache/pip
+ import_tasks: cleanup-user.yml
+ vars:
+ become: true
+ user: root
+ when: root_cache_exists.stat.exists
+
+- name: du ~phd/.cache/pip
+ import_tasks: show-user.yml
+ vars:
+ user: phd
+ when: user_cache_exists.stat.exists
+
+- name: du ~root/.cache/pip
+ import_tasks: show-user.yml
+ vars:
+ user: root
+ when: root_cache_exists.stat.exists