mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
putting look back in, do some linting #2124
This commit is contained in:
parent
d2869b2f22
commit
87eeec7180
2 changed files with 16 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
bugfixes:
|
bugfixes:
|
||||||
- consul_kv lookup - use ``self.get_option`` and
|
- consul_kv lookup - use ``self.get_option`` and
|
||||||
remove the function parse_params all together with its for loop
|
remove the function parse_params get key form self.terms
|
||||||
(https://github.com/ansible-collections/community.general/issues/2124).
|
(https://github.com/ansible-collections/community.general/issues/2124).
|
||||||
|
|
|
@ -126,7 +126,6 @@ class LookupModule(LookupBase):
|
||||||
|
|
||||||
# get options
|
# get options
|
||||||
self.set_options(direct=kwargs)
|
self.set_options(direct=kwargs)
|
||||||
key = terms[0].split(' ')[0]
|
|
||||||
scheme = self.get_option('scheme')
|
scheme = self.get_option('scheme')
|
||||||
host = self.get_option('host')
|
host = self.get_option('host')
|
||||||
port = self.get_option('port')
|
port = self.get_option('port')
|
||||||
|
@ -148,20 +147,22 @@ class LookupModule(LookupBase):
|
||||||
|
|
||||||
values = []
|
values = []
|
||||||
try:
|
try:
|
||||||
consul_api = consul.Consul(host=host, port=port, scheme=scheme, token=token, dc=datacenter,
|
for term in terms:
|
||||||
verify=validate_certs, cert=client_cert)
|
key = term.split(' ')[0]
|
||||||
|
consul_api = consul.Consul(host=host, port=port, scheme=scheme, token=token,
|
||||||
|
dc=datacenter,verify=validate_certs, cert=client_cert)
|
||||||
|
|
||||||
results = consul_api.kv.get(key,
|
results = consul_api.kv.get(key,
|
||||||
index=index,
|
index=index,
|
||||||
recurse=recurse,
|
recurse=recurse,
|
||||||
)
|
)
|
||||||
if results[1]:
|
if results[1]:
|
||||||
# responds with a single or list of result maps
|
# responds with a single or list of result maps
|
||||||
if isinstance(results[1], list):
|
if isinstance(results[1], list):
|
||||||
for r in results[1]:
|
for r in results[1]:
|
||||||
values.append(to_text(r['Value']))
|
values.append(to_text(r['Value']))
|
||||||
else:
|
else:
|
||||||
values.append(to_text(results[1]['Value']))
|
values.append(to_text(results[1]['Value']))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise AnsibleError(
|
raise AnsibleError(
|
||||||
"Error locating '%s' in kv store. Error was %s" % (key, e))
|
"Error locating '%s' in kv store. Error was %s" % (key, e))
|
||||||
|
|
Loading…
Reference in a new issue