From b60b6433a8000459b40c4fdcee1da4fe436729a9 Mon Sep 17 00:00:00 2001 From: fkuep Date: Sun, 28 Mar 2021 00:50:28 +0100 Subject: [PATCH] Wire token param into consul_api #2124 --- changelogs/fragments/2124-consul_kv-pass-token.yml | 5 +++++ plugins/lookup/consul_kv.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/2124-consul_kv-pass-token.yml diff --git a/changelogs/fragments/2124-consul_kv-pass-token.yml b/changelogs/fragments/2124-consul_kv-pass-token.yml new file mode 100644 index 0000000000..cf74b14e9c --- /dev/null +++ b/changelogs/fragments/2124-consul_kv-pass-token.yml @@ -0,0 +1,5 @@ +--- +bugfixes: + - plugins/lookup/consul_kv.py - use self.get_option and + wire the exsisting token attribute into consul_api call. + (https://github.com/ansible-collections/community.general/issues/2124) diff --git a/plugins/lookup/consul_kv.py b/plugins/lookup/consul_kv.py index 7ba7e5ac90..4c13d5c3e0 100644 --- a/plugins/lookup/consul_kv.py +++ b/plugins/lookup/consul_kv.py @@ -138,6 +138,7 @@ class LookupModule(LookupBase): host = u.hostname if u.port is not None: port = u.port + token = self.get_option('token') validate_certs = self.get_option('validate_certs') client_cert = self.get_option('client_cert') @@ -146,7 +147,7 @@ class LookupModule(LookupBase): try: for term in terms: params = self.parse_params(term) - consul_api = consul.Consul(host=host, port=port, scheme=scheme, verify=validate_certs, cert=client_cert) + consul_api = consul.Consul(host=host, port=port, scheme=scheme, token=token, verify=validate_certs, cert=client_cert) results = consul_api.kv.get(params['key'], token=params['token'],