From 62766cf1fd721d278e95821e05e6b41f7888eed5 Mon Sep 17 00:00:00 2001 From: boom2 Date: Tue, 21 Nov 2023 14:11:56 -0500 Subject: initial commit --- .../09-playbook-remove-files-with-wildcard.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 ansible-practice/09-playbook-remove-files-with-wildcard.yml (limited to 'ansible-practice/09-playbook-remove-files-with-wildcard.yml') 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 }}" +... -- cgit v1.2.3-54-g00ecf