community.general.from_ini (8.5.0) — filter

Converts INI text input into a dictionary

| "added in version" 8.2.0 of community.general"

Authors: Steffen Scheib (@sscheib)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Converts INI text input into a dictionary.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - name: Slurp an INI file
    ansible.builtin.slurp:
      src: /etc/rhsm/rhsm.conf
    register: rhsm_conf
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - name: Display the INI file as dictionary
    ansible.builtin.debug:
      var: rhsm_conf.content | b64decode | community.general.from_ini
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - 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
        }}

Inputs

    
_input:
    description: A string containing an INI document.
    required: true
    type: string

Outputs

_value:
  description: A dictionary representing the INI file.
  type: dictionary