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
This can be achieved with the stat module to skip the task when file exists.
- hosts: servers tasks: - name: Ansible check file exists. stat: path: /etc/issue register: p - debug: msg: "File exists..." when: p.stat.exists - debug: msg: "File not found" when: p.stat.exists == False