blob: e0c0b624944d5bd5e8ad71b236a16efbfb9a1922 [file] [log] [blame]
Samuli Silvius45550572019-04-18 11:08:19 +03001---
2- name: Cleanup data from instance (doing it from hosts requires root access).
3 hosts: resources
4 gather_facts: false
5 ignore_unreachable: true
6 pre_tasks:
7 - name: Find files and dirs to delete
8 find:
9 paths: /data/ # Only deleting content not dir itself as we get "Device or resource busy" error as it's mounted to container doing the deletion
10 patterns: "*"
11 recurse: true
12 file_type: any
13 register: files_to_delete
14 - name: Make file/dir path list
15 set_fact:
16 to_delete_paths: "{{ to_delete_paths | default([]) + [item.path] }}"
17 loop: "{{ files_to_delete.files }}"
18 when: files_to_delete.files is defined
19 roles:
20 - role: cleanup-directories
21 vars:
22 directories_files_list_to_remove: "{{ to_delete_paths }}"
23 when: to_delete_paths is defined