I want to read the attributes under <PropertySection>
from the following file using ansible:
<?xml version='1.0' encoding='UTF-8'?>
<Environment xmlns="http://schemas.dmtf.org/ovf/environment/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oe="http://schemas.dmtf.org/ovf/environment/1" xmlns:ve="http://www.vmware.com/schema/ovfenv" oe:id="" ve:vCenterId="vm-6863">
<PlatformSection>
<Kind>VMware ESXi</Kind>
<Version>6.0.0</Version>
<Vendor>VMware, Inc.</Vendor>
<Locale>en</Locale>
</PlatformSection>
<PropertySection>
<Property oe:key="dns" oe:value="test.myeng.com"/>
<Property oe:key="dns-servers" oe:value="8.8.8.8"/>
<Property oe:key="gateway" oe:value="192.168.100.1"/>
<Property oe:key="mask" oe:value="255.255.255.0"/>
</PropertySection>
<ve:EthernetAdapterSection>
<ve:Adapter ve:mac="00:50:56:90:2d:a3" ve:network="VM Network" ve:unitNumber="7"/>
</ve:EthernetAdapterSection>
</Environment>
Reading elements from the <PlatformSection>
seems easy enough but I cannot figure out how to read a specific Property
from the <PropertySection>
- hosts: localhost
tasks:
- name: Read XML
xml:
path: /tmp/input.xml
xpath: /a:Environment/a:PlatformSection/a:Version
content: text
namespaces:
a: http://schemas.dmtf.org/ovf/environment/1
register: xml_out
- debug: var=xml_out