How Do You Troubleshoot the Ansible Error “directory was skipped as it does not seem to be a valid directory or it cannot be accessed”?

Problem scenario
You are using Ansible's find module.  You want it to find the destination of a symbolic link.  When you run the playbook you have a way of finding what the find module returns.  It is saying something about "directory was skipped as it does not seem to be a valid directory or it cannot be accessed."  What should you do?

Solution
Use the stat module.  Instead of the "paths" attribute use the "path" attribute.  

You can register the return value with "register".  If the variable is named foo, you can find the destination of the symbolic link with something like this:

shell:  echo "{{ foo.stat.lnk_target }}" > /tmp/destination.txt 

Leave a comment

Your email address will not be published. Required fields are marked *