I am attempting to edit configuration files for various servers using Ansible and have run into an XML document that has multiple attributes with the same name where the value needs to be adjusted depending on the server state. The config file shrunken down looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<Document>
<properties>
<property name="daily.backup.filename">test.data.thin</property>
<property name="admin.ui.allow.manual.backup.download">false</property>
<property name="admin.ui.allow">false</property>
</properties>
</Document>
This config file would have over 50 properties with different names. My aim is to adjust the data within that single property without using lineinfile module.
Currently, I am able to read the specific value I need but the value will change if the order changes.
- hosts: localhost
tasks:
- name: Read an element's attribute values
xml:
path: /tmp/test.xml
xpath: /Document/properties/property
content: text
register: xmlresp
- name: Show an attribute value
debug:
var: xmlresp.matches[2]
Now I just need to be able to write new information for the "admin.ui.allow.manual.backup.download" property. Like changing the content to "true" or "True"