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
pull/50531/head
Jad Kik 6 years ago committed by René Moser
parent ca91ac2ca0
commit 79eeea8ea6

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

Loading…
Cancel
Save