win_xml – Add XML fragment to an XML parent — Ansible Documentation

- AnsibleFest
- Products
- Community
- Webinars & Training
- Blog

Documentation

# win_xml – Add XML fragment to an XML parent

New in version 2.7.

- Synopsis
- Parameters
- Examples
- Return Values
- Status

## Synopsis

- Adds XML fragments formatted as strings to existing XML on remote servers.
- For non-Windows targets, use the xml module instead.

## Parameters

Parameter | Choices/Defaults | Comments
--- | --- | ---
attribute string |  | The attribute name if the type is 'attribute'. Required if `type=attribute`.
backup boolean | Choices: no ← yes | Determine whether a backup should be created. When set to `yes`, create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly.
fragment string / required |  | The string representation of the XML fragment to be added. aliases: xmlstring
path path / required |  | The path of remote servers XML. aliases: dest, file
type string / required | Choices: attribute element ← text | The type of XML you are working with.
xpath string / required |  | The node of the remote server XML where the fragment will go.

## Examples

    - name: Apply our filter to Tomcat web.xml
      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
      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

## Return Values

Common return values are documented here, the following are the fields unique to this module:

Key | Returned | Description
--- | --- | ---
backup_file string | if backup=yes | Name of the backup file that was created. Sample: C:\Path\To\File.txt.11540.20150212-220915.bak
err list | always, for type element and -vvv or more | XML comparison exceptions. Sample: attribute mismatch for actual=string
msg string | always | What was done. Sample: xml added

## Status

- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]

### Authors

- Richard Levenberg (@richardcs)

Hint

If you notice any issues in this documentation you can edit this document to improve it.