У меня есть и массив xmldocument, полученный из API остальных.
<ArrayOfXmlDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<XmlDocument>
<input xmlns="urn:opendaylight:params:xml:ns:yang:topology:pcep">
.....
</input>
</XmlDocument>
<XmlDocument>
<input xmlns="urn:opendaylight:params:xml:ns:yang:topology:pcep">
.....
</input>
</XmlDocument>
<XmlDocument>
<input xmlns="urn:opendaylight:params:xml:ns:yang:topology:pcep">
.....
</input>
</XmlDocument>
</ArrayOfXmlDocument>
с использованием Ansible Мне нужно получить элемент и все элементы внутри элемента ввода и отправить его в API.
Просто пример элемента ввода:
<input xmlns="urn:opendaylight:params:xml:ns:yang:topology:pcep">
<node>pcc://7.188.102.54</node>
<name>LSP--LAB--LAB/LSP--LAB--LAB-PRI</name>
<arguments>
<lsp xmlns="urn:opendaylight:params:xml:ns:yang:pcep:ietf:stateful">
<delegate>true</delegate>
<administrative>true</administrative>
</lsp>
<ero>
<subobject>
<loose>false</loose>
<ip-prefix>
<ip-prefix>10.10.12.2/32</ip-prefix>
</ip-prefix>
</subobject>
<subobject>
<loose>false</loose>
<ip-prefix>
<ip-prefix>10.10.26.2/32</ip-prefix>
</ip-prefix>
</subobject>
</ero>
</arguments>
<network-topology-ref xmlns:topo="urn:TBD:params:xml:ns:yang:network-topology">/topo:network-topology/topo:topology[topo:topology-id="pcep-topology"]</network-topology-ref>
</input>
</XmlDocument>
Это моя пьеса:
tasks:
- name: Check if service interface exists, fail if true and changes are not allowed
xml:
path: pcepxml.xml
xpath: /ArrayOfXmlDocument/XmlDocument/*
content: text
#count: yes
register: xmlresp
#failed_when: doccount.count == 0
- name: Print
debug:
var: xmlresp
пробовал xmlresp.matches[0]
, xmlresp.matches.XmlDocument
и другие опции, но всегда получаются следующие output.
TASK [Print] ******************************************************************************************************************************************************************************************
ok: [localhost] => {
"xmlresp": {
"actions": {
"namespaces": {},
"state": "present",
"xpath": "/ArrayOfXmlDocument/XmlDocument/*"
},
"changed": false,
"count": 24,
"failed": false,
"matches": [
{
"{urn:opendaylight:params:xml:ns:yang:topology:pcep}input": "\n "
},
{
"{urn:opendaylight:params:xml:ns:yang:topology:pcep}input": "\n "
},
...
],
"msg": 24
}
}
Каков наилучший вариант для получения каждого ввода и его публикации в API? API принимает только один входной элемент на вызов.
Спасибо.
С уважением.