Member-only story
How to Delete Only Files Inside a Directory — Ansible module find
How to automate the search and delete of the files and directories inside a directory keeping the main folder with Ansible modules find and file.
5 min readMay 10, 2022
How to Delete Only Files Inside a Directory with Ansible?
I’m going to show you a live demo with some simple Ansible code.
I’m Luca Berton and welcome to today’s episode of Ansible Pilot.
Ansible How to Delete Only Files Inside a Directory
- `
ansible.builtin.find
` - Return a list of files based on specific criteria
Today we’re talking about the Ansible module `find
`.
The full name is `ansible.builtin.find
`, which means that is part of the collection included in the `ansible-core
` builtin collection.
This module returns a list of files based on specific criteria using the `find` popular Unix command.
Parameters
- paths string — List of paths of directories to search