ansible.builtin.from_yaml_all filter – Convert a series of YAML documents into a variable structure

Note

This filter plugin is part of ansible-core and included in all Ansible installations. In most cases, you can use the short plugin name from_yaml_all. However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.from_yaml_all for easy linking to the plugin documentation and to avoid conflicting with other collections that may have the same filter plugin name.

Synopsis

  • Converts a YAML documents in a string representation into an equivalent structured Ansible variable.

  • Ansible internally auto-converts YAML strings into variable structures in most contexts, but by default does not handle ‘multi document’ YAML files or strings.

  • If multiple YAML documents are not supplied, this is the equivalence of using from_yaml.

Input

This describes the input of the filter, the value before | ansible.builtin.from_yaml_all.

Parameter

Comments

Input

string / required

A YAML string.

Notes

Note

  • This filter functions as a wrapper to the Python yaml.safe_load_all function, part of the pyyaml Python library.

  • Possible conflicts in variable names from the multiple documents are resolved directly by the pyyaml library.

Examples

# variable from string variable containing YAML documents
{{ multidoc_yaml_string | from_yaml_all }}

# variable from multidocument YAML string
{{ '---\n{"a": true, "b": 54, "c": [1,2,3]}\n...\n---{"x": 1}\n...\n' | from_yaml_all }}

Return Value

Key

Description

Return value

any

The variable resulting from deserializing the YAML documents.

Returned: success

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.