Folder tidy
This step relies entirely on the find step, so it uses several variables: The module used to remove files is the file module. The next step in the task is to remove the files that find has uncovered. This is important because I want Ansible to perform a second action on the results of find, so those results need to be stored somewhere for the next step. The finishing touch to this step is to invoke the register module, which saves the results of the find process into a variable called result. csv, but I'm confident that I'm willing to remove. The patterns parameter tells Ansible what to count as a match. Ansible only targets the CSV files I save straight to Downloads (which is my habit). This gives me the ability to retain CSV files that I've downloaded and saved into a subdirectory. The recurse: false parameter forbids Ansible from searching in subdirectories of Downloads. The paths parameter tells Ansible where to search for files.
FOLDER TIDY HOW TO
Here's how to find CSV files in Downloads with Ansible:
But they hang around for weeks until I get overwhelmed and delete them. They get downloaded weekly, processed, and then ought to disappear. In my case, the files I accidentally collect in my Downloads folder are CSV files. This is my process when I start writing a playbook: I find a module in the Ansible module index that seems likely to do what I need, and then I read through its parameters to find out what kind of control I have over the module. In this example playbook, I want to find files explicitly located in the ~/Downloads folder and I can define that using the paths parameter. If an Ansible module is a command, its parameters are its command options. You can locate files on a system using the find Ansible module. Once you have those lines in a text file, you can start defining the steps in your task.
They're the "shebang" ( #!) of Ansible playbooks. Welcome to the communityĬommit those three lines to memory.