Removes hashing from merge_configs.py
There is no benefit to hashing in merge_configs.py In fact, the opposite is true, hashes can collide. This does a direct compare rather than hash. Change-Id: I9ab7af13e813e2267984092027daf1658faf5bf3 Closes-Bug: #1478494
This commit is contained in:
parent
3b394581ab
commit
53c0ada479
@ -50,9 +50,8 @@ Merge multiple configs:
|
|||||||
- "/etc/mysql/my.cnf"
|
- "/etc/mysql/my.cnf"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import ConfigParser
|
from ConfigParser import ConfigParser
|
||||||
from hashlib import sha1
|
from cStringIO import StringIO
|
||||||
from StringIO import StringIO
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
@ -67,20 +66,22 @@ def main():
|
|||||||
dest = module.params.pop('dest')
|
dest = module.params.pop('dest')
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
dest_digest = None
|
|
||||||
fakedest = StringIO()
|
|
||||||
|
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser()
|
||||||
|
|
||||||
for source_file in sources:
|
for source_file in sources:
|
||||||
config.read(source_file)
|
config.read(source_file)
|
||||||
|
|
||||||
if os.path.exists(dest) and os.access(dest, os.R_OK):
|
if os.path.exists(dest) and os.access(dest, os.R_OK):
|
||||||
|
fakedest = StringIO()
|
||||||
config.write(fakedest)
|
config.write(fakedest)
|
||||||
with open(dest, 'rb') as f:
|
with open(dest, 'rb') as f:
|
||||||
dest_digest = sha1(f.read()).hexdigest()
|
files_match = f.read() == fakedest.getvalue()
|
||||||
|
|
||||||
if dest_digest != sha1(fakedest.getvalue()).hexdigest():
|
else:
|
||||||
|
files_match = False
|
||||||
|
|
||||||
|
if not files_match:
|
||||||
changed = True
|
changed = True
|
||||||
with open(dest, 'wb') as f:
|
with open(dest, 'wb') as f:
|
||||||
config.write(f)
|
config.write(f)
|
||||||
|
Loading…
Reference in New Issue
Block a user