lookup: redis: fix plugin returning repr'd byte objects (#52854)

* Fix default port of redis lookup plugin

* Fix redis plugin returning repr'd byte objects

* Fix error handling in redis lookup plugin
This commit is contained in:
Jad Kik 2019-02-27 13:04:18 +02:00 committed by René Moser
parent ca91ac2ca0
commit 79eeea8ea6

View file

@ -28,7 +28,7 @@ DOCUMENTATION = """
key: host
port:
description: port on which Redis is listening on
default: 6379A
default: 6379
type: int
env:
- name: ANSIBLE_REDIS_PORT
@ -75,6 +75,7 @@ try:
except ImportError:
pass
from ansible.module_utils._text import to_text
from ansible.errors import AnsibleError
from ansible.plugins.lookup import LookupBase
@ -104,7 +105,8 @@ class LookupModule(LookupBase):
res = conn.get(term)
if res is None:
res = ""
ret.append(res)
except Exception:
ret.append("") # connection failed or key not found
ret.append(to_text(res))
except Exception as e:
# connection failed or key not found
raise AnsibleError('Encountered exception while fetching {0}: {1}'.format(term, e))
return ret