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:
/etc/
- name: checking th
You can use Ansible stat module to register the file, and when module to apply the condition.
- name: Register file stat: path: "/tmp/test_file" register: file_path - name: Create file if it doesn't exists file: path: "/tmp/test_file" state: touch when: file_path.stat.exists == False