ansible.builtin.rekey_on_member filter – Rekey a list of dicts into a dict using a member

Note

This filter plugin is part of ansible-core and included in all Ansible installations. In most cases, you can use the short plugin name rekey_on_member even without specifying the collections: keyword. However, we recommend you use the FQCN for easy linking to the plugin documentation and to avoid conflicting with other collections that may have the same filter plugin name.

New in ansible-core 2.13

Synopsis

  • Iterate over several iterables in parallel, producing tuples with an item from each one.

Input

This describes the input of the filter, the value before | ansible.builtin.rekey_on_member.

Parameter

Comments

Input

dictionary / required

Original dictionary.

Positional parameters

This describes positional parameters of the filter. These are the values positional1, positional2 and so on in the following example: input | ansible.builtin.rekey_on_member(positional1, positional2, ...).

Parameter

Comments

duplicates

string

How to handle duplicates.

Choices:

  • "overwrite"

  • "error" ← (default)

Keyword parameters

This describes keyword parameters of the filter. These are the values key1=value1, key2=value2 and so on in the following example: input | ansible.builtin.rekey_on_member(key1=value1, key2=value2, ...).

Parameter

Comments

_key

string / required

The key to rekey.

Examples

# mydict => {'eigrp': {'state': 'enabled', 'proto': 'eigrp'}, 'ospf': {'state': 'enabled', 'proto': 'ospf'}}
 mydict: '{{ [{"proto": "eigrp", "state": "enabled"}, {"proto": "ospf", "state": "enabled"}] | rekey_on_member("proto") }}'

Return Value

Key

Description

Return value

dictionary

The resulting dictionary.

Returned: success

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.