ansible xml module - set namespace & namespaced elements
I need to change the following xml
<network>
<name>docker-machines</name>
<uuid>ea91ff7c-aa2b-4fa9-b59d-d1fae70285ad</uuid>
...
</network>
to
<network xmlns:dnsmasq='http://libvirt.org/schemas/network/dnsmasq/1.0'>
<name>docker-machines</name>
<uuid>ea91ff7c-aa2b-4fa9-b59d-d1fae70285ad</uuid>
...
<dns>
<forwarder addr='5.1.66.255'/>
</dns>
<dnsmasq:options>
<dnsmasq:option value='dhcp-option=option:ntp-server,10.10.14.1'/>
</dnsmasq:options>
</network>
I have successfully managed to set the <dns><forwarder>
elemnent using this:
- name: Set resolver for docker-machines network
xml:
path: /etc/libvirt/qemu/networks/docker-machines.xml
xpath: /network/dns
set_children:
- forwarder:
addr: 8.8.8.8
Unfortunately, creating the namespaced elements does not seem to be that easy. For example, I have tried this:
- name: Set ntp server for docker-machines network dhcp
xml:
path: /etc/libvirt/qemu/networks/docker-machines.xml
xpath: /network/dnsmasq:options/dnsmasq:option
namespaces:
dnsmasq: http://libvirt.org/schemas/network/dnsmasq/1.0
attribute: value
value: "dhcp-option=option:ntp-server,10.10.14.1"
...but it does the correctly set the namespace on <network>
and instead creates weird <ns0:>
elements.
How can I do this correctly?
Comments
Post a Comment