Hello,
Is there an alternate to the file command that would prevent overriding a file on a server (and then fail) if it detects that the file has been manually changed since the last play?
This could be helpful in a mixed environment where some people still have access to the server and may change some configuration without remembering to do the changes in Ansible config files.
I since that at least palletops has this feature, I guess it is doing so by keeping a hash somewhere on the server.
Regards,
The file command doesn’t replace contents of files.
If you are thinking of copy, that parameter is force=no.
Yes, I meant the copy command.
Does the force flag detect whether the remote file has been modified externally ? I thought it was just a flag working in a binary way: copy the file the first time, and do not copy again if present (with no check on the content). Which is not the behavior I was describing.
I use xattr command to keep md5sum of the files I copy, then compare it on
the current file, this lets me detect when it was changed externally.
Thanks for the answer Brian.
So there’s no built-in support. I can live with that, just wanted to check I hadn’t overlooked the obvious.
Cheers
The copy command does use the md5sum utility when possible to minimize copying.
This is not always possible under sudo.