How Do You Troubleshoot the Ansible Message ‘Error while linking: [Errno 2] No such file or directory … “state”: “absent”‘?

Problem scenario
You are using the file module in Ansible.  But you get the error 'Error while linking: [Errno 2] No such file or directory ... "state": "absent"'.

What should you do?

Solution
Some people get this problem with different versions of Ansible 2.x.  It is documented on this external page.

Rewrite your Ansible playbook so it uses a "shell" module and some "ln -s" command. Here is an example of the shell command:

ln -s /existing/directory/ /new/directory/via/softlink

# Where /existing/directory/ is the path of an existing directory and "/new/directory/via/softlink" is the symbolic link you 

Leave a comment

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