community.general.redis (0.2.1) — module

Various redis commands, slave and flush

Authors: Xabier Larrakoetxea (@slok)

Install collection

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


Add to requirements.yml

  collections:
    - name: community.general
      version: 0.2.1

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 slave of melee.island on port 6377
  redis:
    command: slave
    master_host: melee.island
    master_port: 6377
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Deactivate slave mode
  redis:
    command: slave
    slave_mode: master
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Flush all the redis db
  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
  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
  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
  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
  redis:
    command: config
    name: lua-time-limit
    value: 100

Inputs

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

name:
    description:
    - A redis config key.

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

command:
    choices:
    - config
    - flush
    - slave
    description:
    - The selected redis command
    - C(config) (new in 1.6), ensures a configuration setting on an instance.
    - C(flush) flushes all the instance or a specified db.
    - C(slave) sets a redis instance in slave or master mode.
    required: true

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

login_host:
    default: localhost
    description:
    - The host running the database

login_port:
    default: 6379
    description:
    - The port to connect to

slave_mode:
    choices:
    - master
    - slave
    default: slave
    description:
    - the mode of the redis instance [slave command]

master_host:
    description:
    - The host of the master instance [slave command]

master_port:
    description:
    - The port of the master instance [slave command]

login_password:
    description:
    - The password used to authenticate with (usually not used)

See also