community.general.from_ini filter – Converts INI text input into a dictionary

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.

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

New in community.general 8.2.0

Synopsis

  • Converts INI text input into a dictionary.

Input

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

Parameter

Comments

Input

string / required

A string containing an INI document.

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.from_ini(key1=value1, key2=value2, ...)

Parameter

Comments

delimiters

list / elements=string

added in community.general 12.4.0

A list of characters used as delimiters in the INI document.

Default: ["=", ":"]

See Also

See also

community.general.to_ini filter plugin

Converts a dictionary to the INI file format.

ansible.builtin.ini lookup plugin

read data from an ini file.

community.general.ini_file

Tweak settings in INI files.

Examples

- name: Slurp an INI file
  ansible.builtin.slurp:
    src: /etc/rhsm/rhsm.conf
  register: rhsm_conf

- name: Display the INI file as dictionary
  ansible.builtin.debug:
    var: rhsm_conf.content | b64decode | community.general.from_ini

- name: Set a new dictionary fact with the contents of the INI file
  ansible.builtin.set_fact:
    rhsm_dict: >-
      {{
          rhsm_conf.content | b64decode | community.general.from_ini
      }}

Return Value

Key

Description

Return value

dictionary

A dictionary representing the INI file.

Returned: success

Authors

  • Steffen Scheib (@sscheib)

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.