问题
i have below Ansible playbook to access my server and fetch data using REST API mechanism, and i am able to get output XML format, but struggling to parse only specific values from that output.
Ansible Playbook - debug
- debug:
var: steering
- debug: msg="{{ steering | regex_findall('<name>(.*?)</name>') }}"
- debug: msg="{{ steering | regex_findall('<value>(.*?)</value>') }}"
Output of last 2 debug responses
TASK [debug] ****************************************************************************************************************************
ok: [localhost] => {
"msg": [
"ip-address",
"start-port",
"end-port",
"realm-id",
]
}
TASK [debug] ****************************************************************************************************************************
ok: [localhost] => {
"msg": [
"10.10.10.12",
"7000",
"15000",
"Core",
How can i fetch only name & values
together instead of separate debug responses (by modifying regex_findall).. or else please help if there is any possibility to merge last debug responses to get name & values
together.
Expected Output
"ip-address - 10.10.10.12",
"start-port - 7000",
"end-port - 15000",
"realm-id - Core"
Please help..
thanks in advance.
来源:https://stackoverflow.com/questions/60023625/ansible-how-to-parse-xml-values-from-uri-rest-xml-output