mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-07-02 00:28:52 +00:00
Make shell outs to md5sum work on FreeBSD and OS X
Tested with OS X local connection and Linux remote. The paths to the md5sum and md5 commands are hardcoded to the most common location. This will definitely fail if the commands are elsewhere, or if the md5 command doesn't support the -q 'quiet' option.
This commit is contained in:
parent
c0a5d91592
commit
834f6a216d
3 changed files with 7 additions and 7 deletions
|
|
@ -60,9 +60,9 @@ if not os.path.exists(src):
|
|||
md5sum = None
|
||||
changed = False
|
||||
if os.path.exists(dest):
|
||||
md5sum = os.popen("md5sum %s" % dest).read().split()[0]
|
||||
md5sum = os.popen("/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s" % {"file": dest}).read().split()[0]
|
||||
|
||||
md5sum2 = os.popen("md5sum %s" % src).read().split()[0]
|
||||
md5sum2 = os.popen("/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s" % {"file": src}).read().split()[0]
|
||||
|
||||
if md5sum != md5sum2:
|
||||
os.system("cp %s %s" % (src, dest))
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ md5sum = None
|
|||
if not os.path.exists(ansible_file):
|
||||
changed = True
|
||||
else:
|
||||
md5sum = os.popen("md5sum %s" % ansible_file).read().split()[0]
|
||||
md5sum = os.popen("/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s" % {"file": ansible_file}).read().split()[0]
|
||||
|
||||
# Get some basic facts in case facter or ohai are not installed
|
||||
for (k, v) in ansible_facts().items():
|
||||
|
|
@ -394,7 +394,7 @@ reformat = json.dumps(setup_options, sort_keys=True, indent=4)
|
|||
f.write(reformat)
|
||||
f.close()
|
||||
|
||||
md5sum2 = os.popen("md5sum %s" % ansible_file).read().split()[0]
|
||||
md5sum2 = os.popen("/usr/bin/md5sum %(file)s 2> /dev/null || /sbin/md5 -q %(file)s" % {"file": ansible_file}).read().split()[0]
|
||||
|
||||
if md5sum != md5sum2:
|
||||
changed = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue