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

* 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>
This commit is contained in:
mklassen 2020-09-30 07:11:28 -04:00 committed by GitHub
parent 75d1894866
commit 0243eabd30
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):