community.general.redis (8.5.0) — module

Various redis commands, replica and flush

Authors: Xabier Larrakoetxea (@slok)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Unified utility to interact with redis instances.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Deactivate replica mode
  community.general.redis:
    command: replica
    replica_mode: master
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Flush all the redis db
  community.general.redis:
    command: flush
    flush_mode: all
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Flush only one db in a redis instance
  community.general.redis:
    command: flush
    db: 1
    flush_mode: db
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Configure local redis to have 10000 max clients
  community.general.redis:
    command: config
    name: maxclients
    value: 10000
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Configure local redis maxmemory to 4GB
  community.general.redis:
    command: config
    name: maxmemory
    value: 4GB
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Configure local redis to have lua time limit of 100 ms
  community.general.redis:
    command: config
    name: lua-time-limit
    value: 100

Inputs

    
db:
    description:
    - The database to flush (used in db mode) [flush command]
    type: int

tls:
    default: false
    description:
    - Specify whether or not to use TLS for the connection.
    type: bool
    version_added: 4.6.0
    version_added_collection: community.general

name:
    description:
    - A redis config key.
    type: str

value:
    description:
    - 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.
    type: str

command:
    choices:
    - config
    - flush
    - replica
    - slave
    description:
    - The selected redis command
    - V(config) ensures a configuration setting on an instance.
    - V(flush) flushes all the instance or a specified db.
    - V(replica) sets a redis instance in replica or master mode. (V(slave) is an alias
      for V(replica).)
    type: str

ca_certs:
    description:
    - Path to root certificates file. If not set and O(tls) is set to V(true), certifi
      ca-certificates will be used.
    type: str
    version_added: 4.6.0
    version_added_collection: community.general

flush_mode:
    choices:
    - all
    - db
    default: all
    description:
    - Type of flush (all the dbs in a redis instance or a specific one) [flush command]
    type: str

login_host:
    default: localhost
    description:
    - Specify the target host running the database.
    type: str

login_port:
    default: 6379
    description:
    - Specify the port to connect to.
    type: int

login_user:
    description:
    - Specify the user to authenticate with.
    - Requires L(redis,https://pypi.org/project/redis) >= 3.4.0.
    type: str
    version_added: 4.6.0
    version_added_collection: community.general

master_host:
    description:
    - The host of the master instance [replica command]
    type: str

master_port:
    description:
    - The port of the master instance [replica command]
    type: int

replica_mode:
    aliases:
    - slave_mode
    choices:
    - master
    - replica
    - slave
    default: replica
    description:
    - The mode of the redis instance [replica command]
    - V(slave) is an alias for V(replica).
    type: str

login_password:
    description:
    - Specify the password to authenticate with.
    - Usually not used when target is localhost.
    type: str

validate_certs:
    default: true
    description:
    - Specify whether or not to validate TLS certificates.
    - This should only be turned off for personally controlled sites or with C(localhost)
      as target.
    type: bool
    version_added: 4.6.0
    version_added_collection: community.general

See also