diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
commit | 8a754e0858d922e955e71b253c139e071ecec432 (patch) | |
tree | 527d16e74bfd1840c85efd675fdecad056c54107 /lib/ansible/plugins/filter/items2dict.yml | |
parent | Initial commit. (diff) | |
download | ansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/ansible/plugins/filter/items2dict.yml')
-rw-r--r-- | lib/ansible/plugins/filter/items2dict.yml | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/ansible/plugins/filter/items2dict.yml b/lib/ansible/plugins/filter/items2dict.yml new file mode 100644 index 0000000..1352c67 --- /dev/null +++ b/lib/ansible/plugins/filter/items2dict.yml @@ -0,0 +1,48 @@ +DOCUMENTATION: + name: items2dict + author: Ansible core team + version_added: "2.7" + short_description: Consolidate a list of itemized dictionaries into a dictionary + positional: _input, key_name, value_name + 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). + options: + _input: + description: + - A list of dictionaries. + - Every dictionary must have keys C(key) and C(value). + type: list + elements: dict + required: true + key_name: + description: The name of the key in the element dictionaries that holds the key to use at destination. + type: str + default: key + value_name: + description: The name of the key in the element dictionaries that holds the value to use at destination. + type: str + default: value + seealso: + - plugin_type: filter + plugin: ansible.builtin.dict2items + +EXAMPLES: | + # mydict => { "hi": "bye", "ciao": "ciao" } + mydict: {{ [{'key': 'hi', 'value': 'bye'}, {'key': 'ciao', 'value': 'ciao'} ]| items2dict}} + + # The output is a dictionary with two key/value pairs: + # Application: payment + # Environment: dev + vars: + tags: + - key: Application + value: payment + - key: Environment + value: dev + consolidated: "{{ tags | items2dict }}" + +RETURN: + _value: + description: Dictionary with the consolidated key/values. + type: dict |