community.general.to_ini filter – Converts a dictionary to the INI file format
Note
This filter plugin is part of the community.general collection (version 12.6.1).
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.
To use it in a playbook, specify: community.general.to_ini.
New in community.general 8.2.0
Synopsis
- Converts a dictionary to the INI file format.
Input
This describes the input of the filter, the value before | community.general.to_ini.
Parameter | Comments |
|---|---|
Input dictionary / required | The dictionary that should be converted to the INI format. |
See Also
See also
- ansible.builtin.ini lookup plugin
-
read data from an ini file.
- community.general.ini_file
-
Tweak settings in INI files.
- community.general.from_ini filter plugin
-
Converts INI text input into a dictionary.
Examples
- name: Define a dictionary
ansible.builtin.set_fact:
my_dict:
section_name:
key_name: 'key value'
another_section:
connection: 'ssh'
- name: Write dictionary to INI file
ansible.builtin.copy:
dest: /tmp/test.ini
content: '{{ my_dict | community.general.to_ini }}'
# /tmp/test.ini will look like this:
# [section_name]
# key_name = key value
#
# [another_section]
# connection = ssh
Return Value
Key | Description |
|---|---|
Return value string | A string formatted as INI file. Returned: success |
Collection links
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/projects/ansible/latest/collections/community/general/to_ini_filter.html