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

0 votes

I'm very new to Ansible and I have to work on a project. I need to do the following

  • Determine if a path exists and is a symlink
  • If it does not exist, test sym.stat.islnk and should fail with an error

How do I write a playbook for the same?

Apr 2, 2019 in Ansible by Ishaan
7,382 views

1 answer to this question.

0 votes

Hi @neha, you can write your task in the following way:

- stat:
    path: /path/to/something
  register: sym

- debug:
    msg: "islnk isn't defined (path doesn't exist)"
  when: sym.stat.islnk is not defined

Try and let me know if it works.

answered Apr 2, 2019 by Alok

Related Questions In Ansible

0 votes
1 answer

Ansible task to check if PGP key is installed on Ubuntu

Hi @hannah, have a look at this, ...READ MORE

answered Nov 25, 2019 in Ansible by Aria
1,073 views
+1 vote
2 answers

Running ansible command on a single server when it is deployed to multiple servers

You can try the run_once attribute: Example from ...READ MORE

answered Jun 14, 2018 in Ansible by DareDev
• 6,890 points
2,413 views
+1 vote
1 answer

Is it possible to append a large amount of text to a file using Ansible?

Here is concept which you can follow. blockinfile is ...READ MORE

answered Jul 30, 2018 in Ansible by Atul
• 10,240 points
14,522 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
3,929 views
+2 votes
1 answer
0 votes
1 answer

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

Hi @Nisha, use the stat module provided ...READ MORE

answered Apr 2, 2019 in Ansible by Alok
11,245 views
0 votes
1 answer

Is there a way to recover lost Ansible Vault password?

Hey @Sridhar, There is no way to ...READ MORE

answered Jan 29, 2019 in Ansible by Akthia
2,854 views
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