Member-only story
Check if a file exists — Ansible module stat
How to check if a file exists in Ansible? I’m going to show you a live demo and some simple Ansible code. I’m going to show you how to combine the “stat” module with conditional to verify an existing and not existing path.
How to check if a file exists in 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 check file exists
Today we’re talking about the Ansible module `stat`.
The full name is `ansible.builtin.stat`, 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 retrieves a file entry or a file system status.
Mandatory Parameters
- path string