Lossless file command ?

45 views
Skip to first unread message

Laurent PETIT

unread,
Jun 15, 2014, 4:50:28 PM6/15/14
to ansible...@googlegroups.com
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,

-- 
Laurent Petit

Michael DeHaan

unread,
Jun 15, 2014, 9:24:16 PM6/15/14
to ansible...@googlegroups.com
The file command doesn't replace contents of files.

If you are thinking of copy, that parameter is force=no.




--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c3f0321b-bdab-468c-b1e5-bdbd4e93aa2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Laurent PETIT

unread,
Jun 16, 2014, 1:37:56 AM6/16/14
to ansible...@googlegroups.com
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. 

Brian Coca

unread,
Jun 16, 2014, 11:14:25 AM6/16/14
to ansible...@googlegroups.com
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.



--
Brian Coca
Stultorum infinitus est numerus
0110000101110010011001010110111000100111011101000010000001111001011011110111010100100000011100110110110101100001011100100111010000100001
Pedo mellon a minno

Laurent PETIT

unread,
Jun 16, 2014, 4:03:35 PM6/16/14
to ansible...@googlegroups.com
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
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

Michael DeHaan

unread,
Jun 17, 2014, 3:03:42 PM6/17/14
to ansible...@googlegroups.com
The copy command does use the md5sum utility when possible to minimize copying.

This is not always possible under sudo.



Reply all
Reply to author
Forward
0 new messages