Note
This lookup plugin is part of the community.general collection (version 10.7.3).
You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.general. You need further requirements to be able to use this lookup plugin, see Requirements for details.
To use it in a playbook, specify: community.general.redis.
The below requirements are needed on the local controller node that executes this lookup.
Parameter | Comments |
|---|---|
Terms list / elements=string | List of keys to query. |
This describes keyword parameters of the lookup. These are the values key1=value1, key2=value2 and so on in the following examples: lookup('community.general.redis', key1=value1, key2=value2, ...) and query('community.general.redis', key1=value1, key2=value2, ...)
Parameter | Comments |
|---|---|
host string | Location of Redis host. Default: Configuration:
|
port integer | Port on which Redis is listening on. Default: Configuration:
|
socket path | Path to socket on which to query Redis, this option overrides host and port options when set. Configuration:
|
Note
Configuration entries listed above for each entry type (Ansible variable, environment variable, and so on) have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up. The entry types are also ordered by precedence from low to high priority order. For example, an ansible.cfg entry (further up in the list) is overwritten by an Ansible variable (further down in the list).
Note
lookup('community.general.redis', term1, term2, key1=value1, key2=value2) and query('community.general.redis', term1, term2, key1=value1, key2=value2)
- name: query redis for somekey (default or configured settings used)
ansible.builtin.debug:
msg: "{{ lookup('community.general.redis', 'somekey') }}"
- name: query redis for list of keys and non-default host and port
ansible.builtin.debug:
msg: "{{ lookup('community.general.redis', item, host='myredis.internal.com', port=2121) }}"
loop: '{{list_of_redis_keys}}'
- name: use list directly
ansible.builtin.debug:
msg: "{{ lookup('community.general.redis', 'key1', 'key2', 'key3') }}"
- name: use list directly with a socket
ansible.builtin.debug:
msg: "{{ lookup('community.general.redis', 'key1', 'key2', socket='/var/tmp/redis.sock') }}"
Key | Description |
|---|---|
Return value list / elements=string | Value(s) stored in Redis. Returned: success |
© 2012–2018 Michael DeHaan
© 2018–2025 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/redis_lookup.html