community.general.dict_kv (8.5.0) — filter

Convert a value to a dictionary with a single key-value pair

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

Authors: Stanislav German-Evtushenko (@giner)

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

Convert a value to a dictionary with a single key-value pair.

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create a one-element dictionary from a value
  ansible.builtin.debug:
    msg: "{{ 'myvalue' | dict_kv('mykey') }}"

Inputs

    
key:
    description: The key for the single key-value pair.
    required: true
    type: any

_input:
    description: The value for the single key-value pair.
    required: true
    type: any

Outputs

_value:
  description: A dictionary with a single key-value pair.
  type: dictionary