community.general.to_toml filter – Convert variable to TOML string

Note

This filter plugin is part of the community.general collection (version 12.4.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general. You need further requirements to be able to use this filter plugin, see Requirements for details.

To use it in a playbook, specify: community.general.to_toml.

New in community.general 12.3.0

Synopsis

  • Converts an Ansible variable into a TOML string representation.

  • This filter functions as a wrapper to the Python TOML Kit library‘s tomlkit.dumps function.

Requirements

The below requirements are needed on the local controller node that executes this filter.

  • tomlkit

Input

This describes the input of the filter, the value before | community.general.to_toml.

Parameter

Comments

Input

dictionary / required

A variable or expression that returns a data structure.

Keyword parameters

This describes keyword parameters of the filter. These are the values key1=value1, key2=value2 and so on in the following example: input | community.general.to_toml(key1=value1, key2=value2, ...)

Parameter

Comments

redact_sensitive_values

boolean

If set to true, vaulted strings are replaced by <redacted> instead of being decrypted.

With future ansible-core versions, this can extend to other strings tagged as sensitive.

Note that with ansible-core 2.18 and before this might not yield the expected result since these versions of ansible-core strip the vault information away from strings that are part of more complex data structures specified in vars.

Choices:

  • false ← (default)

  • true

Examples

---
# Dump variable in a template to create a TOML document
value: "{{ my_config | community.general.to_toml }}"

Return Value

Key

Description

Return value

string

The TOML serialized string representing the variable structure inputted.

Returned: success

Authors

  • Matt Williaks (@milliams)

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.