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

Convert a dictionary into an itemized list of dictionaries

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

Authors: Ansible core team

Install Ansible via pip

Install with pip install ansible-core==2.16.0

Description

Takes a dictionary and transforms it into a list of dictionaries, with each having a C(key) and C(value) keys that correspond to the keys and values of the original.

Inputs

    
_input:
    description:
    - The dictionary to transform
    required: true
    type: dict

key_name:
    default: key
    description: The name of the property on the item representing the dictionary's keys.
    type: str
    version_added: '2.8'
    version_added_collection: ansible.builtin

value_name:
    default: value
    description: The name of the property on the item representing the dictionary's values.
    type: str
    version_added: '2.8'
    version_added_collection: ansible.builtin

Outputs

_value:
  description: A list of dictionaries.
  elements: dict
  type: list

See also