community.general.redis – Various redis commands, replica and flush
Note
This plugin is part of the community.general collection (version 3.8.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
.
To use it in a playbook, specify: community.general.redis
.
Parameters
Parameter |
Comments |
---|---|
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:
|
|
The host running the database Default: “localhost” |
|
The password used to authenticate with (usually not used) |
|
The port to connect to Default: 6379 |
|
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:
|
|
A redis config value. When memory size is needed, it is possible to specify it in the usal form of 1KB, 2M, 400MB where the base is 1024. Units are case insensitive i.e. 1m = 1mb = 1M = 1MB. |
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
See Also
See also
- community.general.redis_info
The official documentation on the community.general.redis_info module.
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
Authors
Xabier Larrakoetxea (@slok)