ansible.builtin.win_xml (v2.8.20) — module

Add XML fragment to an XML parent

| "added in version" 2.7 of ansible.builtin"

Authors: Richard Levenberg (@richardcs)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.8.20

Description

Adds XML fragments formatted as strings to existing XML on remote servers.

For non-Windows targets, use the M(xml) module instead.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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: '/*'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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

Inputs

    
path:
    aliases:
    - dest
    - file
    description:
    - The path of remote servers XML.
    required: true
    type: path

type:
    choices:
    - attribute
    - element
    - text
    default: element
    description:
    - The type of XML you are working with.
    required: true
    type: str

xpath:
    description:
    - The node of the remote server XML where the fragment will go.
    required: true
    type: str

backup:
    default: false
    description:
    - Determine whether a backup should be created.
    - When set to C(yes), create a backup file including the timestamp information so
      you can get the original file back if you somehow clobbered it incorrectly.
    type: bool

fragment:
    aliases:
    - xmlstring
    description:
    - The string representation of the XML fragment to be added.
    required: true
    type: str

attribute:
    description:
    - The attribute name if the type is 'attribute'.
    - Required if C(type=attribute).
    type: str

Outputs

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