diff options
| author | Jenkins <jenkins@review.openstack.org> | 2015-07-28 08:00:12 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2015-07-28 08:00:12 +0000 |
| commit | 615bbc1861bccdcf2025dbaa85b82992580d1641 (patch) | |
| tree | c21a871af9e5b69d4b4ebf9a0b19f2f0d4ffa934 | |
| parent | 521a671ef9be4df2c8ad571514817039bef467e9 (diff) | |
| parent | 53c0ada479815ef019e2a79bcf9e85d66810bb3a (diff) | |
| download | kolla-615bbc1861bccdcf2025dbaa85b82992580d1641.tar.gz kolla-615bbc1861bccdcf2025dbaa85b82992580d1641.zip | |
Merge "Removes hashing from merge_configs.py"
| -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) |
