How to check if a file exists in Ansible?

Question:

I have to check whether a file exists in /etc/. If the file exists then I have to skip the task.
Here is the code I am using:

Answer:

You can first check that the destination file exists or not and then make a decision based on the output of its result:

Leave a Reply