to_nice_yaml¶
Collection Note
This module is part of the ansible.builtin collection. To install the collection, use:
Added in versionhistorical.
Synopsis¶
- 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.
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| _input raw required |
A variable or expression that returns a data structure. | |
| indent integer |
Number of spaces to indent Python structures, mainly used for display to humans. | |
| sort_keys bool |
Default: True |
Affects sorting of dictionary keys. |
Notes¶
Note
- More options may be available, see L(PyYAML documentation, https://pyyaml.org/wiki/PyYAMLDocumentation) for details.
- These parameters to C(yaml.dump) will be ignored, as they are overridden internally: I(default_flow_style)
Examples¶
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| _value | string | The YAML serialized string representing the variable structure inputted. |
Authors¶
- Core Team