The task seems simple. If the file does not exist, create it, otherwise retain the file and its content. In both cases, apply permissions (owner
, group
, mode
).
The most obvious candidate to this task is ansible.builtin.file
with state: touch
. However, it always appears as changed as the times need to be updated. Rather, once it exists and modes are ok, it should just be ok.
The next candidate likely is ansible.builtin.copy
. If passing force: false
, it creates the file. However, it does not fix up permission on an already existing file.