collection 교체

This commit is contained in:
정훈 변
2024-02-23 16:37:40 +09:00
parent b494779b5b
commit 3fd554eee9
38862 changed files with 220204 additions and 6600073 deletions

View File

@@ -9,35 +9,36 @@ The get_path lookup plugin
"""
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = """
name: get_path
author: Bradley Thornton (@cidrblock)
plugin_type: lookup
version_added: "1.0.0"
short_description: Retrieve the value in a variable using a path
description:
- Use a I(path) to retrieve a nested value from a I(var)
- B(get_path) is also available as a B(filter plugin) for convenience
- Using the parameters below- C(lookup('ansible.utils.get_path', var, path, wantlist))
- Use a I(path) to retrieve a nested value from a I(var)
- B(get_path) is also available as a B(filter plugin) for convenience
- Using the parameters below- C(lookup('ansible.utils.get_path', var, path, wantlist))
options:
var:
description: The variable from which the value should be extracted.
description:
- The variable from which the value should be extracted.
type: raw
required: True
path:
description: >
The I(path) in the I(var) to retrieve the value of.
The I(path) needs to a be a valid jinja path.
description:
- The I(path) in the I(var) to retrieve the value of.
- The I(path) needs to a be a valid jinja path.
type: str
required: True
wantlist:
description: >
If set to C(True), the return value will always be a list.
This can also be accomplished using C(query) or C(q) instead of C(lookup).
U(https://docs.ansible.com/ansible/latest/plugins/lookup.html).
description:
- If set to C(True), the return value will always be a list.
- This can also be accomplished using C(query) or C(q) instead of C(lookup).
- U(https://docs.ansible.com/ansible/latest/plugins/lookup.html).
type: bool
notes:
@@ -49,11 +50,11 @@ EXAMPLES = r"""
b:
c:
d:
- 0
- 1
- 0
- 1
e:
- True
- False
- true
- false
- name: Retrieve a value deep inside a using a path
ansible.builtin.set_fact:
@@ -133,9 +134,9 @@ EXAMPLES = r"""
rekeyed:
by_name: "{{ interfaces.gathered|ansible.builtin.rekey_on_member('name') }}"
loop:
- by_name['Ethernet1/1'].description
- by_name['Ethernet1/2'].description|upper
- by_name['Ethernet1/3'].description|default('')
- by_name['Ethernet1/1'].description
- by_name['Ethernet1/2'].description|upper
- by_name['Ethernet1/3'].description|default('')
# TASK [Get the description of several interfaces] ******************
@@ -145,7 +146,6 @@ EXAMPLES = r"""
# msg: CONFIGURED BY ANSIBLE
# ok: [nxos101] => (item=by_name['Ethernet1/3'].description|default('')) => changed=false
# msg: ''
"""
RETURN = """
@@ -157,12 +157,11 @@ RETURN = """
from ansible.errors import AnsibleLookupError
from ansible.plugins.lookup import LookupBase
from ansible_collections.ansible.utils.plugins.module_utils.common.get_path import (
get_path,
)
from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
AnsibleArgSpecValidator,
)
from ansible_collections.ansible.utils.plugins.module_utils.common.get_path import get_path
class LookupModule(LookupBase):
@@ -171,9 +170,9 @@ class LookupModule(LookupBase):
keys = ["var", "path"]
terms = dict(zip(keys, terms))
terms.update(kwargs)
aav = AnsibleArgSpecValidator(
data=terms, schema=DOCUMENTATION, name="get_path"
)
schema = [v for k, v in globals().items() if k.lower() == "documentation"]
aav = AnsibleArgSpecValidator(data=terms, schema=schema[0], name="get_path")
valid, errors, updated_data = aav.validate()
if not valid:
raise AnsibleLookupError(errors)