set file permission ONLY if file exists?

489 views
Skip to first unread message

Jörgen Hägg

unread,
Nov 17, 2015, 9:52:54 AM11/17/15
to Ansible Project
I'm trying to use the file module to set permissions on files that exists.
The manual says that state=file will do so, but I still get an error, "is absent, cannot continue".

From the manual for state: "If file, the file will NOT be created if it does not exist"

Is this how it is supposed to work?

ansible 1.9.4, debian sid


file: path={{item}} mode=0664 owner=xxx group=yyy state=file
with_items:
- logfile1
- logfile2 ...

Brian Coca

unread,
Nov 17, 2015, 5:58:40 PM11/17/15
to Ansible Project
the error is correct the file does not exist and the permissions
cannot be updated

ignore_errors: yes will allow for it to keep running even if the file
does not exist, another option is using the stat: module to check if
the file exists and run file: conditionally on that.


--
Brian Coca
Reply all
Reply to author
Forward
0 new messages