Skip to content

win_xml type: attribute with state: absent not functioning as intended #631

@owadestig

Description

@owadestig
SUMMARY

win_xml remove attribute broken. Intended behavior:

- name: Remove attribute
  community.windows.win_xml:
    path: some_path
    xpath: /some/xpath/some_element
    state: absent
    type: attribute
    attribute: some_attribute

Should remove attribute some_attribute if the element some_element has it. Will reach else block in win_xml.ps1 starting on line 266. Here it fails the if statement if ($node.Name -eq $attribute ) . If statement should be if ($node.HasAttribute($attribute)) instead.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

win_xml.ps1

ANSIBLE VERSION
ansible [core 2.15.9]
COLLECTION VERSION
community.windows 2.3.0
CONFIGURATION

OS / ENVIRONMENT

windows virtual machine

STEPS TO REPRODUCE

See bug description.

EXPECTED RESULTS

attribute removed

ACTUAL RESULTS

attribute not removed. No error logged. No description of what happened, code doesn't cover this specific case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghas_prThis issue has an associated PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions