diff options
| author | Sam Yaple <sam@yaple.net> | 2015-07-27 10:06:55 +0000 |
|---|---|---|
| committer | Sam Yaple <sam@yaple.net> | 2015-07-27 10:06:55 +0000 |
| commit | 53c0ada479815ef019e2a79bcf9e85d66810bb3a (patch) | |
| tree | 39bfb3c28cdc347e7fb17eb419b29daaa12d1469 | |
| parent | 3b394581ab52bb476cdc9bed0ec1e95e0ce43669 (diff) | |
| download | kolla-53c0ada479815ef019e2a79bcf9e85d66810bb3a.tar.gz kolla-53c0ada479815ef019e2a79bcf9e85d66810bb3a.zip | |
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
| -rw-r--r-- | ansible/library/merge_configs.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/ansible/library/merge_configs.py b/ansible/library/merge_configs.py index 61d667be7..155291d0e 100644 --- a/ansible/library/merge_configs.py +++ b/ansible/library/merge_configs.py @@ -50,9 +50,8 @@ Merge multiple configs: - "/etc/mysql/my.cnf" ''' -import ConfigParser -from hashlib import sha1 -from StringIO import StringIO +from ConfigParser import ConfigParser +from cStringIO import StringIO def main(): module = AnsibleModule( @@ -67,20 +66,22 @@ def main(): dest = module.params.pop('dest') changed = False - dest_digest = None - fakedest = StringIO() - config = ConfigParser.ConfigParser() + config = ConfigParser() for source_file in sources: config.read(source_file) if os.path.exists(dest) and os.access(dest, os.R_OK): + fakedest = StringIO() config.write(fakedest) 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 with open(dest, 'wb') as f: config.write(f) |
