lookup: consul_kv: Add datacenter parameter (#56647)

This commit is contained in:
Jake Scaltreto 2019-05-22 02:02:39 -04:00 committed by René Moser
parent d8c1f67862
commit 3e8ca0285f

View file

@ -31,6 +31,11 @@ DOCUMENTATION = """
index: index:
description: description:
- If the key has a value with the specified index then this is returned allowing access to historical values. - If the key has a value with the specified index then this is returned allowing access to historical values.
datacenter:
default: None
description:
- Retrieve the key from a consul datatacenter other than the default for the consul host.
version_added: "2.9"
token: token:
description: The acl token to allow access to restricted values. description: The acl token to allow access to restricted values.
host: host:
@ -144,7 +149,8 @@ class LookupModule(LookupBase):
results = consul_api.kv.get(params['key'], results = consul_api.kv.get(params['key'],
token=params['token'], token=params['token'],
index=params['index'], index=params['index'],
recurse=params['recurse']) recurse=params['recurse'],
dc=params['datacenter'])
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):
@ -165,7 +171,8 @@ class LookupModule(LookupBase):
'key': params[0], 'key': params[0],
'token': None, 'token': None,
'recurse': False, 'recurse': False,
'index': None 'index': None,
'datacenter': None
} }
# parameters specified? # parameters specified?