From b3063e37be01ad7d4266fe2d2956896f02b97ce5 Mon Sep 17 00:00:00 2001 From: Johannes Brunswicker Date: Thu, 11 Oct 2018 15:35:49 +0200 Subject: [PATCH] Convert results with to_native in consul_kv plugin (#46551) * #42851 convert results with to_native * added missing ANSIBLE_METADATA * removed unneeded brackets * * replaced to_native with to_text to avoid getting bytecode --- lib/ansible/plugins/lookup/consul_kv.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ansible/plugins/lookup/consul_kv.py b/lib/ansible/plugins/lookup/consul_kv.py index 63ef4c631f..1b49a53959 100644 --- a/lib/ansible/plugins/lookup/consul_kv.py +++ b/lib/ansible/plugins/lookup/consul_kv.py @@ -5,6 +5,10 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type +ANSIBLE_METADATA = {'metadata_version': '1.1', + 'status': ['preview'], + 'supported_by': 'community'} + DOCUMENTATION = """ lookup: consul_kv version_added: "1.9" @@ -99,8 +103,7 @@ import os from ansible.module_utils.six.moves.urllib.parse import urlparse from ansible.errors import AnsibleError, AnsibleAssertionError from ansible.plugins.lookup import LookupBase - -import json +from ansible.module_utils._text import to_text try: import consul @@ -146,9 +149,9 @@ class LookupModule(LookupBase): # responds with a single or list of result maps if isinstance(results[1], list): for r in results[1]: - values.append(r['Value']) + values.append(to_text(r['Value'])) else: - values.append(results[1]['Value']) + values.append(to_text(results[1]['Value'])) except Exception as e: raise AnsibleError( "Error locating '%s' in kv store. Error was %s" % (term, e))