Debian Codegraph @

lib/ansible/plugins/lookup/list.py

raw
1 # (c) 2012-17 Ansible Project
2 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
3
4 from __future__ import annotations
5
6
7 DOCUMENTATION = """
8 name: list
9 author: Ansible Core Team
10 version_added: "2.0"
11 short_description: simply returns what it is given.
12 description:
13 - this is mostly a noop, to be used as a with_list loop when you dont want the content transformed in any way.
14 """
15
16 EXAMPLES = """
17 - name: unlike with_items you will get 3 items from this loop, the 2nd one being a list
18 ansible.builtin.debug: var=item
19 with_list:
20 - 1
21 - [2,3]
22 - 4
23 """
24
25 RETURN = """
26 _list:
27 description: basically the same as you fed in
28 type: list
29 elements: raw
30 """
31
32 from collections.abc import Sequence
33
34 from ansible.plugins.lookup import LookupBase
35 from ansible.errors import AnsibleError
36
37
38 class LookupModule(LookupBase):
39
40 def run(self, terms, variables=None, **kwargs):
41 if not isinstance(terms, Sequence):
42 raise AnsibleError("with_list expects a list")
43 return terms