Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
win_xml module for manipulating XML files on Windows #26404
win_xml module for manipulating XML files on Windows #26404
Changes from all commits
1d0b00c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this being used for anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used to determine the debug level See below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, is this being used for anything. I'm also not sure what the Ansible practice is around returning extra values based on the verbosity level set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The $debug variable is used to determine whether to return XML comparison errors. I can take all the functionality out or take the debug gate out. This was work in concert with removing the emission of the errors to a log on the remote server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@richardcs I am trying to remove an element from xml file but its not working for me. I am trying following, Please correct me if i am doing wrong.
- name: Running XML Transformations with state Absent win_xml: path: "path\to\xml\file" xpath: "/configuration/configSections/sectionGroup/section[@name='authentication']" state: "absent" fragment: " "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the xpath be
//configuration/configSections/sectionGroup/section[@name='authentication']
- double initial slash?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petemounce it worked for other paramerters without adding double initial slash. its not working only if i am trying to delete an element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think you can have an empty fragment. The xpath should find the root of your XML where the child fragment is, then it will remove that child fragment.
So to guess maybe your xpath is "/configuration/configSections/sectionGroup/" and your fragment is "section[@name='authentication']"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petemounce "//" means find it at the root, which is probably artificially the case, but not explicitly necessary .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@richardcs one last thing that i want to know, Can we add the capability to delete even the attributes from the elements?
We are trying to remove only the attributes from the xml element.
For. Ex
<language default="eng" style="arial"></language>
We want to delete the default attribute only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the current module supports absent for attributes. If you give me the .xml you are working with I can probably add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@richardcs Here is the xml file.
we want to remove a attribute
serializeAs="String"
which is present in<setting name="Setting1" serializeAs="String">
element.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abhijeetka I modified the win_xml module to support your use case. It was tested with this playbook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@richardcs that works like a charm ...!! Thanks for adding this functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you also able to add the
backup
anderr
return values and a description for those.