Manages XML file content on Windows hosts
- Manages XML nodes, attributes and text, using xpath to select which xml nodes need to be managed.
- XML fragments, formatted as strings, are used to specify the desired state of a part or parts of XML files on remote Windows servers.
- For non-Windows targets, use the :ref:`community.general.xml <community.general.xml_module>` module instead.
Note
- Only supports operating on xml elements, attributes and text.
- Namespace, processing-instruction, command and document node types cannot be modified with this module.
.. seealso:: :ref:`community.general.xml_module` XML manipulation for Posix hosts. `w3shools XPath tutorial <https://www.w3schools.com/xml/xpath_intro.asp>`_ A useful tutorial on XPath
- name: Apply our filter to Tomcat web.xml
community.windows.win_xml:
path: C:\apache-tomcat\webapps\myapp\WEB-INF\web.xml
fragment: '<filter><filter-name>MyFilter</filter-name><filter-class>com.example.MyFilter</filter-class></filter>'
xpath: '/*'
- name: Apply sslEnabledProtocols to Tomcat's server.xml
community.windows.win_xml:
path: C:\Tomcat\conf\server.xml
xpath: '//Server/Service[@name="Catalina"]/Connector[@port="9443"]'
attribute: 'sslEnabledProtocols'
fragment: 'TLSv1,TLSv1.1,TLSv1.2'
type: attribute
- name: remove debug configuration nodes from nlog.conf
community.windows.win_xml:
path: C:\IISApplication\nlog.conf
xpath: /nlog/rules/logger[@name="debug"]/descendant::*
state: absent
- name: count configured connectors in Tomcat's server.xml
community.windows.win_xml:
path: C:\Tomcat\conf\server.xml
xpath: //Server/Service/Connector
count: yes
register: connector_count
- name: show connector count
debug:
msg="Connector count is {{connector_count.count}}"
- name: ensure all lang=en attributes to lang=nl
community.windows.win_xml:
path: C:\Data\Books.xml
xpath: //@[lang="en"]
attribute: lang
fragment: nl
type: attribute
Common return values are documented here, the following are the fields unique to this module:
- Richard Levenberg (@richardcs)
- Jon Hawkesworth (@jhawkesworth)