---
- hosts: myservers
remote_user: deploy
become: yes
become_method: sudo
vars:
FOO_CONF: /tmp/foo.conf
# Check for the existance of /tmp/foo.conf
# place the results into foo_conf_file
# check "{{ FOO_CONF }}".stat.exists
tasks:
- name: Check file
stat: path="{{ FOO_CONF }}"
register: foo_conf_file
- debug: msg="Oops File does not exist"
when: foo_conf_file.stat.exists == False
- debug: msg="Check permissions"
when: foo_conf_file.stat.mode == '0600'