community / community.general / 3.8.10 / filter / groupby_as_dict Transform a sequence of dictionaries to a dictionary where the dictionaries are indexed by an attribute | "added in version" 3.1.0 of community.general" Authors: Felix Fontein (@felixfontein)community.general.groupby_as_dict (3.8.10) — filter
Install with ansible-galaxy collection install community.general:==3.8.10
collections: - name: community.general version: 3.8.10
Transform a sequence of dictionaries to a dictionary where the dictionaries are indexed by an attribute.
- name: Arrange a list of dictionaries as a dictionary of dictionaries ansible.builtin.debug: msg: "{{ sequence | community.general.groupby_as_dict('key') }}" vars: sequence: - key: value foo: bar - key: other_value baz: bar
_input: description: A list of dictionaries elements: dictionary required: true type: list attribute: description: The attribute to use as the key. required: true type: str
_value: description: A dictionary containing the dictionaries from the list as values. type: dictionary