diff options
author | Dag Wieers <dag@wieers.com> | 2017-08-24 17:45:21 +0200 |
---|---|---|
committer | Dag Wieers <dag@wieers.com> | 2017-08-24 17:48:48 +0200 |
commit | efbd60f1536a7269029cc9e80a7147839f189c2e (patch) | |
tree | beab9cc8072a18e5cc9dbb6f3ec96aab28d7dfdd | |
parent | 000ccc838a384311ee55f6972f237b9223702612 (diff) | |
download | ansible-xml-backup.tar.gz |
xml module: Add backup to pretty_print tooxml-backup
-rw-r--r-- | lib/ansible/modules/files/xml.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/ansible/modules/files/xml.py b/lib/ansible/modules/files/xml.py index 4987fc97fc..4c4a83b0cd 100644 --- a/lib/ansible/modules/files/xml.py +++ b/lib/ansible/modules/files/xml.py @@ -549,6 +549,8 @@ def pretty(module, tree): if xml_string != xml_content.read(): result['changed'] = True if not module.check_mode: + if module.params['backup']: + result['backup_file'] = module.backup_local(module.params['path']) tree.write(xml_file, xml_declaration=True, encoding='UTF-8', pretty_print=module.params['pretty_print']) finally: xml_content.close() @@ -647,12 +649,11 @@ def finish(module, tree, xpath, namespaces, changed=False, msg="", hitcount=0, m after=etree.tostring(tree, xml_declaration=True, encoding='UTF-8', pretty_print=module.params['pretty_print']), ) - if module.params['path']: - if not module.check_mode: - if module.params['backup']: - result['backup_file'] = module.backup_local(module.params['path']) + if module.params['path'] and not module.check_mode: + if module.params['backup']: + result['backup_file'] = module.backup_local(module.params['path']) - tree.write(module.params['path'], xml_declaration=True, encoding='UTF-8', pretty_print=module.params['pretty_print']) + tree.write(module.params['path'], xml_declaration=True, encoding='UTF-8', pretty_print=module.params['pretty_print']) if module.params['xmlstring']: result['xmlstring'] = etree.tostring(tree, xml_declaration=True, encoding='UTF-8', pretty_print=module.params['pretty_print']) |