Skip to content

xml

!xml

Category: files

Edit explicitly selected XML settings without reserializing unrelated configuration. Install prepared edits atomically through the execution-target connection.

Notes

  • Set or remove is required. Selectors support literal ASCII element paths and namespace prefixes, not general XPath. Ambiguous or overlapping selectors fail. Scalar values preserve whole-variable template types; explicit children lists control repeated elements in order while preserving unrelated children. All operations are prepared before any write. Plan never stages or writes; unchanged apply never replaces or notifies. All DTDs and external entity resolution are disabled. See usage/xml-settings for creation, namespace, preservation, and optimistic concurrency details.

Parameters

NameTypeRequiredDescription
pathpathyesAbsolute execution-target UTF-8 XML file path; destination symlinks are rejected.
setmapnoLiteral absolute element selectors mapped to typed scalar values or explicit children mappings of element names to scalar lists.
removelistnoLiteral absolute selectors to remove; absent elements are unchanged. Null is not deletion.
createboolnoExplicitly permit missing files, ancestors, selected elements, and additional repeated children. Default false.
namespacesmapnoExplicit prefix-to-URI bindings for selectors and newly created elements. Unprefixed names select no namespace.
attributesmapnoExplicit owner/group/mode overrides; existing ownership and permissions otherwise remain intact.

Examples

- !xml
  path: /etc/example/network.xml
  create: true
  set:
    /NetworkConfiguration/EnableHttps: false
    /NetworkConfiguration/KnownProxies:
      children:
        string: '{{ trusted_proxy_addresses }}'
  and:
    notify: restart application