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/subelements.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/subelements.yml | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/ansible/plugins/filter/subelements.yml b/lib/ansible/plugins/filter/subelements.yml new file mode 100644 index 0000000..a2d1a94 --- /dev/null +++ b/lib/ansible/plugins/filter/subelements.yml @@ -0,0 +1,38 @@ +DOCUMENTATION: + name: subelements + version_added: "2.7" + short_description: retuns a product of a list and it's elements + positional: _input, _subelement, skip_missing + description: + - This produces a product of an object and the subelement values of that object, similar to the subelements lookup. This lets you specify individual subelements to use in a template I(_input). + options: + _input: + description: Original list. + type: list + elements: any + required: yes + _subelement: + description: Label of property to extract from original list items. + type: str + required: yes + skip_missing: + description: If C(True), ignore missing subelements, otherwise missing subelements generate an error. + type: bool + default: no + +EXAMPLES: | + # data + users: + - groups: [1,2,3] + name: lola + - name: fernando + groups: [2,3,4] + + # user_w_groups =>[ { "groups": [ 1, 2, 3 ], "name": "lola" }, 1 ], [ { "groups": [ 1, 2, 3 ], "name": "lola" }, 2 ], [ { "groups": [ 1, 2, 3 ], "name": "lola" }, 3 ], [ { "groups": [ 2, 3, 4 ], "name": "fernando" }, 2 ], [ { "groups": [ 2, 3, 4 ], "name": "fernando" }, 3 ], [ { "groups": [ 2, 3, 4 ], "name": "fernando" }, 4 ] ] + users_w_groups: {{ users | subelements('groups', skip_missing=True) }} + +RETURN: + _value: + description: List made of original list and product of the subelement list. + type: list + elements: any |