Member-only story

Delete file or directory — Ansible module file

A real-life example about how the “deleteme” file and the “deleteme” directory with Ansible. Tested in a target Linux machine as well for idempotency of the Ansible Playbook.

Luca Berton
4 min readSep 10, 2021

How to Delete files or directory with Ansible?

I’m going to show you a live demo and some simple Ansible code.

I’m Luca Berton and welcome to today’s episode of Ansible Pilot.

Ansible delete file/directory

Today we’re talking about the Ansible module file.
The full name is `ansible.builtin.file`, which means that is part of the collection of modules “builtin” with ansible and shipped with it.
It’s a module pretty stable and out for years.
It works in a different variety of operating systems.
It manages files and file properties.
For Windows targets, use the `ansible.windows.win_file` module instead.

Main Parameters

  • path string (dest, name) — file path

--

--

Luca Berton
Luca Berton

Written by Luca Berton

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday

No responses yet