Fix xml reports changed when node is not deleted (#1007) (#1012)

* Fix xml reports changed when node is not deleted

* Added changelog fragment

* Added tests for xml no change remove

* Added PR to changeling fragment

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 0243eabd30)

Co-authored-by: mklassen <lmklassen@gmail.com>
This commit is contained in:
patchback[bot] 2020-09-30 13:44:57 +02:00 committed by GitHub
parent 572e3f0814
commit e4d3d24b26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 131 additions and 2 deletions

View file

@ -411,8 +411,10 @@ def xpath_matches(tree, xpath, namespaces):
def delete_xpath_target(module, tree, xpath, namespaces):
""" Delete an attribute or element from a tree """
changed = False
try:
for result in tree.xpath(xpath, namespaces=namespaces):
changed = True
# Get the xpath for this result
if is_attribute(tree, xpath, namespaces):
# Delete an attribute
@ -429,7 +431,7 @@ def delete_xpath_target(module, tree, xpath, namespaces):
except Exception as e:
module.fail_json(msg="Couldn't delete xpath target: %s (%s)" % (xpath, e))
else:
finish(module, tree, xpath, namespaces, changed=True)
finish(module, tree, xpath, namespaces, changed=changed)
def replace_children_of(children, match):