diff options
| author | Jenkins <jenkins@review.openstack.org> | 2015-12-23 13:19:08 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2015-12-23 13:19:08 +0000 |
| commit | 027e70f9a270b54f2e41208956262ee89875bd4a (patch) | |
| tree | 60d97c1f3e9072c16358986288f8c9c5d609e775 /ansible/library | |
| parent | bd1fdf3b4ca7f15ccb4fb4ada57ee35a107ad3be (diff) | |
| parent | ed82afa8e928ac7c9f5ad2162be2c27eaab8e2e6 (diff) | |
| download | kolla-027e70f9a270b54f2e41208956262ee89875bd4a.tar.gz kolla-027e70f9a270b54f2e41208956262ee89875bd4a.zip | |
Merge "Simplify config creation"
Diffstat (limited to 'ansible/library')
| -rw-r--r-- | ansible/library/merge_configs.py | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/ansible/library/merge_configs.py b/ansible/library/merge_configs.py index e894322ed..5da09eed1 100644 --- a/ansible/library/merge_configs.py +++ b/ansible/library/merge_configs.py @@ -49,49 +49,3 @@ Merge multiple configs: dest: - "/etc/mysql/my.cnf" ''' - -from ConfigParser import ConfigParser -from cStringIO import StringIO - -def main(): - module = AnsibleModule( - argument_spec = dict( - sources = dict(required=True, type='list'), - dest = dict(required=True, type='str'), - ) - ) - - try: - sources = module.params.pop('sources') - dest = module.params.pop('dest') - - changed = False - - 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: - files_match = f.read() == fakedest.getvalue() - - else: - files_match = False - - if not files_match: - changed = True - with open(dest, 'wb') as f: - config.write(f) - - module.exit_json(changed=changed) - except Exception as e: - module.exit_json(failed=True, changed=changed, msg=repr(e)) - - -# import module snippets -from ansible.module_utils.basic import * -if __name__ == '__main__': - main() |
