community.general.redis module – Various redis commands, replica and flush
Note
This module is part of the community.general collection (version 7.5.2).
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 module,
see Requirements for details.
To use it in a playbook, specify: community.general.redis
.
Synopsis
Unified utility to interact with redis instances.
Aliases: database.misc.redis
Requirements
The below requirements are needed on the host that executes this module.
certifi
redis
Parameters
Parameter |
Comments |
---|---|
Path to root certificates file. If not set and |
|
The selected redis command
Choices:
|
|
The database to flush (used in db mode) [flush command] |
|
Type of flush (all the dbs in a redis instance or a specific one) [flush command] Choices:
|
|
Specify the target host running the database. Default: |
|
Specify the password to authenticate with. Usually not used when target is localhost. |
|
Specify the port to connect to. Default: |
|
Specify the user to authenticate with. Requires redis >= 3.4.0. |
|
The host of the master instance [replica command] |
|
The port of the master instance [replica command] |
|
A redis config key. |
|
The mode of the redis instance [replica command]
Choices:
|
|
Specify whether or not to use TLS for the connection. Choices:
|
|
Specify whether or not to validate TLS certificates. This should only be turned off for personally controlled sites or with Choices:
|
|
A redis config value. When memory size is needed, it is possible to specify it in the usual form of 1KB, 2M, 400MB where the base is 1024. Units are case insensitive i.e. 1m = 1mb = 1M = 1MB. |
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Notes
Note
Requires the redis-py Python package on the remote host. You can install it with pip (pip install redis) or with a package manager. https://github.com/andymccurdy/redis-py
If the redis master instance we are making replica of is password protected this needs to be in the redis.conf in the masterauth variable
Requires the
redis
Python package on the remote host. You can install it with pip (pip install redis
) or with a package manager. Information on the library can be found at https://github.com/andymccurdy/redis-py.
See Also
See also
- community.general.redis_info
Gather information about Redis servers.
Examples
- name: Set local redis instance to be a replica of melee.island on port 6377
community.general.redis:
command: replica
master_host: melee.island
master_port: 6377
- name: Deactivate replica mode
community.general.redis:
command: replica
replica_mode: master
- name: Flush all the redis db
community.general.redis:
command: flush
flush_mode: all
- name: Flush only one db in a redis instance
community.general.redis:
command: flush
db: 1
flush_mode: db
- name: Configure local redis to have 10000 max clients
community.general.redis:
command: config
name: maxclients
value: 10000
- name: Configure local redis maxmemory to 4GB
community.general.redis:
command: config
name: maxmemory
value: 4GB
- name: Configure local redis to have lua time limit of 100 ms
community.general.redis:
command: config
name: lua-time-limit
value: 100