Ansible task to know if a path exists and if its a directory

0 votes
I want to write a playbook that tests whether a path exists and if its a directory. How do i write an Ansible playbook for the same?
Apr 2 in Ansible by Nisha
1,502 views

1 answer to this question.

0 votes

Hi @Nisha, use the stat module provided by Ansible for this:

- stat:
    path: /path/to/something
  register: p
- debug:
    msg: "Path exists and is a directory"
  when: p.stat.isdir is defined and p.stat.isdir
answered Apr 2 by Alok

Related Questions In Ansible

0 votes
1 answer

Create a directory at a specific path using ansible

To create a directory using Ansible, you ...READ MORE

answered Jan 9 in Ansible by Jason
85 views
0 votes
1 answer
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
185 views
0 votes
1 answer
0 votes
1 answer