Skip to content

Instantly share code, notes, and snippets.

@piotr-gbyliczek
Created July 31, 2018 16:26
Show Gist options
  • Save piotr-gbyliczek/482f5cedf36955daa25b94f53b180485 to your computer and use it in GitHub Desktop.
Save piotr-gbyliczek/482f5cedf36955daa25b94f53b180485 to your computer and use it in GitHub Desktop.
- name: find dirs to scan
find:
file_type: directory
path: "{{ item.dir }}"
patterns: "{{ item.pattern }}"
use_regex: yes
register: directories
with_items: "{{ dynamic_directories }}"
- name: find files to remove
find:
file_type: file
path: "{{ item }}"
recurse: yes
register: files_for_removal
with_items:
- "{{ static_directories }}"
- name: find files to remove in directories to scan
find:
file_type: file
path: "{{ item.files.path }}"
recurse: yes
register: files_for_removal_in_dirs_to_scan
with_items:
- "{{ directories.results }}"
- name: remove files
file:
state: absent
path: "{ item.item.path }}"
follow: true
with_items:
- "{{ files_for_removal.results }}"
- "{{ files_for_removal_in_dirs_to_scan.results }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment