1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Make copy module idempotent.

Check md5sum before overwriting a file. Unconditionally copying changes the timestamp.
This commit is contained in:
Jeroen Hoekx 2012-03-31 13:58:15 +02:00
parent 6275e57718
commit 38a33c54a6

View file

@ -54,11 +54,10 @@ changed = False
if os.path.exists(dest):
md5sum = os.popen("md5sum %s" % dest).read().split()[0]
os.system("cp %s %s" % (src, dest))
md5sum2 = os.popen("md5sum %s" % dest).read().split()[0]
md5sum2 = os.popen("md5sum %s" % src).read().split()[0]
if md5sum != md5sum2:
os.system("cp %s %s" % (src, dest))
changed = True
# mission accomplished