Last active
April 28, 2018 21:19
-
-
Save aaam/6263d334e52a4ee8b8de609a8d94ab8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: remove and recreate directory | |
file: | |
state: "{{ item }}" | |
path: "/path/to/directory/" | |
# owner: 1000 set owner, group, and mode if necessary | |
# group: 1000 | |
mode: '0777' # make it full read and writeable | |
with_items: | |
- absent | |
- directory | |
- block: | |
- name: 'search files' | |
find: | |
paths: "/path/to/directory/" | |
hidden: True | |
recurse: True | |
file_type: any | |
register: deletefiles | |
- name: 'seach directories' | |
find: | |
paths: "/path/to/directory/" | |
hidden: True | |
recurse: True | |
file_type: directory | |
register: deletedirectories | |
- name: remove only files and subdirectories | |
file: | |
path: "{{ item.path }}" | |
state: absent | |
with_items: > | |
{{ | |
deletefiles.files | |
+ deletedirectories.files | |
}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment