Skip to content

from_yaml

Collection Note

This module is part of the ansible.builtin collection. To install the collection, use:

ansible-galaxy collection install ansible.builtin
Added in version historical.

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.

Parameters

Parameter Defaults / Choices Comments
_input
string
required
A YAML string.

Notes

Note

  • This filter functions as a wrapper to the L(Python pyyaml library, https://pypi.org/project/PyYAML/)'s C(yaml.safe_load) function.

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 Values

Key Data Type Description Returned
_value raw The variable resulting from deserializing the YAML document.