grzegorznowak.redis
Ansible Role: Redis
This role installs Redis Server on Debian systems.
It's a simple version for setting up multiple Redis configurations on Debian-based systems. It includes thorough testing with Molecule, which allows you to test easily on your local machine. There's also a Docker option if you want to use a container.
The role will create separate configuration files in /etc/redis/redis-{{name}}.conf
and log files in /var/log/redis/
for each configuration.
This role is great for development purposes to try out various configurations on a single machine, as well as for real deployments, thanks to its clean, well-tested code.
It uses systemctl
for LXD or bare-metal setups, and init.d
for Docker.
Requirements
No additional dependencies needed.
Coverage
This role works with the latest Debian-based distributions:
- Ubuntu: 18.04, 16.04
- Debian: Stretch
Variables
Defaults
redis_package_name
: "redis-server"redis_configs
:port
: 6380 # Listening portname
: "cache" # Name of the configuration (affects log and pid file names)bind
: 127.0.0.1 # IP address to bind (using localhost is safest)
Example of multiple configurations
redis_configs:
- port: 6379
name: "cache"
bind: 127.0.0.1
- port: 6380
name: "session"
bind: 127.0.0.1
- port: 8080
name: "shared-cache"
bind: 0.0.0.0
Note: The last configuration opens port 8080 to the internet, so you will need to implement separate security measures (not included in this role).
The role will install the latest stable version available for supported distributions.
Example Playbook
Cloning from GitHub
---
- hosts: all
vars:
redis_configs:
- port: 6379
name: "cache0"
bind: 127.0.0.1
- port: 6380
name: "cache1"
bind: 127.0.0.1
roles:
- role: ansible-redis
From Ansible Galaxy
---
- hosts: all
vars:
redis_configs:
- port: 6379
name: "cache0"
bind: 127.0.0.1
- port: 6380
name: "cache1"
bind: 127.0.0.1
roles:
- role: grzegorznowak.redis
Testing
Requirements
- Molecule Installation Guide
- Molecule LXD Installation Document
- Molecule Docker Installation Document
Testing with LXD Containers
molecule test
Testing with Docker Base Images
molecule test --scenario-name=docker_dev
Additional Features from Molecule
You can use commands like molecule converge
to launch instances as you like, and then use molecule destroy
to remove them. The possibilities are extensive!
Sponsored by
Kwiziq.com - An AI language education platform
Spottmedia.com - Technology design, delivery, and consulting
Author Information
Created with care by Grzegorz Nowak.
Redis multiconf for Ubuntu. Molecule covered. Also builds for vanilla docker machines.
ansible-galaxy install grzegorznowak.redis