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 in Ansible by Ishaan
168 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 by Alok

Related Questions In Ansible

0 votes
1 answer

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 13, 2018 in Ansible by DareDev
• 6,810 points
213 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
3,008 views
0 votes
1 answer
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
212 views
0 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 in Ansible by Alok
1,924 views
0 votes
1 answer