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/dict2items.yml | |
parent | Initial commit. (diff) | |
download | ansible-core-upstream/2.14.3.tar.xz ansible-core-upstream/2.14.3.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | lib/ansible/plugins/filter/dict2items.yml | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/ansible/plugins/filter/dict2items.yml b/lib/ansible/plugins/filter/dict2items.yml new file mode 100644 index 0000000..aa51826 --- /dev/null +++ b/lib/ansible/plugins/filter/dict2items.yml @@ -0,0 +1,45 @@ +DOCUMENTATION: + name: dict2items + author: Ansible core team + version_added: "2.6" + short_description: Convert a dictionary into an itemized list of dictionaries + positional: _input, key_name, value_name + 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. + options: + _input: + description: + - The dictionary to transform + type: dict + required: true + key_name: + description: The name of the property on the item representing the dictionary's keys. + type: str + default: key + version_added: "2.8" + value_name: + description: The name of the property on the item representing the dictionary's values. + type: str + default: value + version_added: "2.8" + seealso: + - plugin_type: filter + plugin: ansible.builtin.items2dict + +EXAMPLES: | + + # items => [ { "key": "a", "value": 1 }, { "key": "b", "value": 2 } ] + items: "{{ {'a': 1, 'b': 2}| dict2items}}" + + vars: + files: + users: /etc/passwd + groups: /etc/group + files_dicts: "{{ files | dict2items(key_name='file', value_name='path') }}" + +RETURN: + _value: + description: A list of dictionaries. + type: list + elements: dict |