I have to check whether a file exists or not in /etc/. If the file exists then I have to skip the task otherwise the task should be run. Below is the code
- name: check whether the file exists
command: touch /etc/file.txt
when: $(! -s /etc/file.txt)
If the file exists then task should be skipped other wise run the task