This module provides high-level tools for managing Redis instances.


Require Redis to be installed from source.

The compiled binaries will be installed in /opt/redis-{version}/.

fabtools.require.redis.instance(name, version='2.6.16', bind='', port=6379, **kwargs)[source]

Require a Redis instance to be running.

The required Redis version will be automatically installed using fabtools.require.redis.installed_from_source() if needed.

You can specify the IP address and port on which to listen to using the bind and port parameters.


Redis is designed to be accessed by trusted clients inside trusted environments. It is usually not a good idea to expose the Redis instance directly to the internet. Therefore, with the default settings, the Redis instance will only listen to local clients.

If you want to make your Redis instance accessible to other servers over an untrusted network, you should probably add some firewall rules to restrict access. For example:

from fabtools import require
from fabtools.shorewall import Ping, SSH, hosts, rule

# The computers that will need to talk to the Redis server

# The Redis server port

# Setup a basic firewall
        rule(port=REDIS_PORT, source=hosts(REDIS_CLIENTS)),

# Make the Redis instance listen on all interfaces
require.redis.instance('mydb', bind='', port=REDIS_PORT)

See also

Redis Security

You can also use any valid Redis configuration directives as extra keyword arguments. For directives that can be repeated on multiple lines (such as save), you can supply a list of values.

The instance will be managed using supervisord, as a process named redis_{name}, running as the redis user.

from fabtools import require
from fabtools.supervisor import process_status


print process_status('redis_mydb')

The default settings enable persistence using periodic RDB snapshots saved in the /var/db/redis directory.

You may want to use AOF persistence instead:

require.redis.instance('mydb', appendonly='yes', save=[])

In certain situations, you may want to disable persistence completely:

require.redis.instance('cache', port=6380, save=[])