ansible.builtin.from_yaml filter – Convert YAML string into 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. However, we recommend you use the Fully Qualified Collection Name (FQCN) ansible.builtin.from_yaml 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 string representation into an equivalent structured Ansible variable.

  • Ansible automatically converts YAML strings into variable structures in most contexts, use this plugin in contexts where automatic conversion does not happen.

Input

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

Parameter

Comments

Input

string / required

A YAML string.

Notes

Note

Examples

# variable from string variable containing a YAML document
{{ github_workflow | from_yaml}}

# variable from string JSON document
{{ '{"a": true, "b": 54, "c": [1,2,3]}' | from_yaml }}

Return Value

Key

Description

Return value

any

The variable resulting from deserializing the YAML document.

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.