Ansible Module xml: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 7: Line 7:


=Example=
=Example=
<syntaxhighlight lang='yaml'>
- name: XML manipulation
  xml:
    path:
</syntaxhighlight>
=Module Parameters=
==<tt>path</tt>==
The path to the file to operate on. The file must exists, otherwise the module will fail, with a message similar to:
<font color='red' size=-1>
The target XML source '/Users/ovidiu/playground/ansible/modules/community.general.xml/test.xml' does not exist.
</font>
The parameter is required unless <code>[[#xmlstring|xmlstring]]</code> is provided.
==<tt>xmlstring</tt>==


<syntaxhighlight lang='yaml'>
<syntaxhighlight lang='yaml'>

Revision as of 20:59, 4 July 2021

External

Internal

Overview

The plugin is named community.general.xml and it offers functionality aimed at interacting with XML files, using XPath.

Example

- name: XML manipulation
  xml:
    path:

Module Parameters

path

The path to the file to operate on. The file must exists, otherwise the module will fail, with a message similar to:

The target XML source '/Users/ovidiu/playground/ansible/modules/community.general.xml/test.xml' does not exist.

The parameter is required unless xmlstring is provided.

xmlstring

- name: Bump Java build heap size to {{build.jvm.heap_max}} MB
  xml:
    path: "{{ansible_env.PROJECT_ROOT}}/.idea/compiler.xml"
    xpath: /project/component[@name='CompilerConfiguration']/option[@name='BUILD_PROCESS_HEAP_SIZE']
    attribute: "value"
    value: "{{build.jvm.heap_max}}"
- name: Set Eclipse as default compiler
  xml:
    path: "{{idea_path}}/.idea/compiler.xml"
    xpath: /project/component[@name='CompilerConfiguration']/option[@name='DEFAULT_COMPILER']
    attribute: "value"
    value: "Eclipse"