ansible.builtin.to_nice_yaml (v2.16.0) — filter

Convert variable to YAML string

| "added in version" historical of ansible.builtin"

Authors: core team

Install Ansible via pip

Install with pip install ansible-core==2.16.0

Description

Converts an Ansible variable into a YAML string representation.

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

Ansible internally auto-converts YAML strings into variable structures so this plugin is used to force it into a YAML string.

Inputs

    
_input:
    description: A variable or expression that returns a data structure.
    required: true
    type: raw

indent:
    description: Number of spaces to indent Python structures, mainly used for display
      to humans.
    type: integer

sort_keys:
    default: true
    description: Affects sorting of dictionary keys.
    type: bool

Outputs

_value:
  description: The YAML serialized string representing the variable structure inputted.
  type: string