Registering value to var causes issues with namespace
shrabok-surge opened this issue · 2 comments
Hello,
I am trying to register a value found in a pom.xml file.
Here is an example of what I've done
xml:
file: "{{ deploy_helper.new_release_path }}/pom.xml"
namespaces:
dom: http://maven.apache.org/POM/4.0.0
xpath: /dom:project/dom:version
content: text
register: jar_version
when I look at the output I expected something I could leverage using filters but the domain format has {}
braces that cant be called in ansible. Here is the output of the var:
"msg": {
"actions": {
"ensure": "present",
"namespaces": {
"dom": "http://maven.apache.org/POM/4.0.0"
},
"xpath": "/dom:project/dom:version"
},
"changed": false,
"count": 1,
"matches": [
{
"{http://maven.apache.org/POM/4.0.0}version": "sprint21"
}
],
"msg": 1
}
If I use "{{ jar_version.matches }}"
I can see the values but I want to use the sprint21 value somewhere else and cant get that part. I thought the content:text
would provide me only the value of the match, but i see that is not the case. Any ideas on how I can get that key value?
And is there anyway to avoid using namespaces and allow all namespaces?
How about
"{{ jar_version.matches[0]['{http://maven.apache.org/POM/4.0.0}version'] }}"
The xml module is upstream now (and ships with Ansible v2.4).
Please close this issue, and if needed, open a new issue at: https://github.com/ansible/ansible/issues