Member-only story

Check if a directory exists — Ansible module stat

Deep dive into the Ansible module stat of the collection “ansible.builtin” to test if a specified path is a directory and print a message. Live demo and Ansible playbook included.

Luca Berton
3 min readAug 7, 2021

How to check if a directory 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 directory 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.

--

--

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