set file permission ONLY if file exists?

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 …

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.