mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 07:01:22 -07:00
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:
parent
ca91ac2ca0
commit
79eeea8ea6
1 changed files with 6 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue