ansible.builtin.items2dict (v2.16.0) — filter

Consolidate a list of itemized dictionaries into a dictionary

| "added in version" 2.7 of ansible.builtin"

Authors: Ansible core team

Install Ansible via pip

Install with pip install ansible-core==2.16.0

Description

Takes a list of dicts with each having a C(key) and C(value) keys, and transforms the list into a dictionary, effectively as the reverse of R(dict2items,ansible_collections.ansible.builtin.dict2items_filter).

Inputs

    
_input:
    description:
    - A list of dictionaries.
    - Every dictionary must have keys C(key) and C(value).
    elements: dict
    required: true
    type: list

key_name:
    default: key
    description: The name of the key in the element dictionaries that holds the key to
      use at destination.
    type: str

value_name:
    default: value
    description: The name of the key in the element dictionaries that holds the value
      to use at destination.
    type: str

Outputs

_value:
  description: Dictionary with the consolidated key/values.
  type: dict

See also