summaryrefslogtreecommitdiff
path: root/ansible-practice/09-playbook-remove-files-with-wildcard.yml
diff options
context:
space:
mode:
Diffstat (limited to 'ansible-practice/09-playbook-remove-files-with-wildcard.yml')
-rw-r--r--ansible-practice/09-playbook-remove-files-with-wildcard.yml21
1 files changed, 21 insertions, 0 deletions
diff --git a/ansible-practice/09-playbook-remove-files-with-wildcard.yml b/ansible-practice/09-playbook-remove-files-with-wildcard.yml
new file mode 100644
index 0000000..046d18d
--- /dev/null
+++ b/ansible-practice/09-playbook-remove-files-with-wildcard.yml
@@ -0,0 +1,21 @@
+# remove multiple files using globbing
+# https://phoenixnap.com/kb/ansible-create-file
+# https://www.freekb.net/Article?id=573
+
+---
+- name: "09 - Playing with Ansible - remove a multiple files with globbing"
+# hosts: all
+ hosts: localhost
+ connection: local
+ tasks:
+ - name: Find files with a pattern
+ find:
+ paths: "~/"
+ patterns: "ansible_created_file*"
+ register: result
+ - name: Remove multiple files with pattern above
+ file:
+ path: "{{ item.path }}"
+ state: absent
+ with_items: "{{ result.files }}"
+...