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, 2019 in Ansible by Nisha
11,319 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, 2019 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, 2019 in Ansible by Jason
1,193 views
0 votes
1 answer
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,062 views
+2 votes
1 answer
0 votes
1 answer

Ansible task to determine if a path exists and is a symlink

Hi @neha, you can write your task ...READ MORE

answered Apr 2, 2019 in Ansible by Alok
7,645 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP