community.general.to_ini (8.5.0) — filter

Converts a dictionary to the INI file format

| "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 a dictionary to the INI file format.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - name: Define a dictionary
    ansible.builtin.set_fact:
      my_dict:
        section_name:
          key_name: 'key value'

        another_section:
          connection: 'ssh'
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
  - name: Write dictionary to INI file
    ansible.builtin.copy:
      dest: /tmp/test.ini
      content: '{{ my_dict | community.general.to_ini }}'

Inputs

    
_input:
    description: The dictionary that should be converted to the INI format.
    required: true
    type: dictionary

Outputs

_value:
  description: A string formatted as INI file.
  type: string