https://github.com/claranet/ansible-role-redis
Install and configure Redis
https://github.com/claranet/ansible-role-redis
ansible claranet redis role
Last synced: 2 months ago
JSON representation
Install and configure Redis
- Host: GitHub
- URL: https://github.com/claranet/ansible-role-redis
- Owner: claranet
- License: mpl-2.0
- Created: 2023-05-03T12:33:22.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-27T14:31:20.000Z (over 2 years ago)
- Last Synced: 2024-03-27T17:57:29.726Z (over 2 years ago)
- Topics: ansible, claranet, redis, role
- Language: Jinja
- Homepage:
- Size: 106 KB
- Stars: 1
- Watchers: 13
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Ansible role - redis
[](https://www.claranet.fr/)
[](LICENSE)
[](https://github.com/claranet/ansible-role-redis/releases)
[](https://github.com/claranet/ansible-role-redis/actions?query=workflow%3A%22Ansible+Molecule%22)
[](https://github.com/ansible/ansible)
[](https://galaxy.ansible.com/claranet/redis)
> :star: Star us on GitHub — it motivates us a lot!
Install and configure Redis
## :warning: Requirements
Ansible >= 2.10
## :zap: Installation
```bash
ansible-galaxy install claranet.redis
```
## :gear: Role variables
Variable | Default value | Description
--------------------------------------|----------------------------------------------------|------------------------------------------------------------------
redis_server_enabled | **true** | enable installation and configuration of redis server
redis_master_ip | **null** | redis master ip. used for clustering scenario
redis_group | **groups.redis** | redis group name in inventory
redis_server_version | **latest** | redis version to install
redis_server_user | **redis** | redis user for configuration
redis_server_group | **redis** | group for redis
redis_server_logdir | **/var/log/redis** | path to log directory
redis_server_databases_number | **16** | number of databases
redis_server_port | **6379** | listen port
redis_server_password | **void** | password for redis authentication
redis_conf.bind | **0.0.0.0** | listen address
redis_conf.supervised | **systemd** | Supervision option
redis_conf.pidfile | **/var/run/redis_{{ redis_server_port }}.pid** | pid file for systemd service
redis_conf.logfile | **redis-server_{{ redis_server_port }}.log** | name of redis log file
redis_conf.dir | **/var/lib/redis** | path of databases files
redis_conf.dbfilename | **{{ redis_server_port }}.rdb** | database filename
redis_conf.maxmemory-policy | **allkeys-lru** | max memory policy
redis_conf.maxmemory | **'{{ autocalculated \| int }}'** | max memory available
redis_conf.replica-priority | **10 (master) / 100 (replica)** | replica priority
redis_conf.appendfilename | **{{ redis_server_port }}.aof** | redis append filename
redis_sentinel_version | **'{{ redis_server_version }}'** | sentinel version to install
redis_sentinel_enabled | **false** | sentinel version to install
redis_sentinel_daemonize | **true** | daemonize redis sentinel
redis_sentinel_listen | **0.0.0.0** | listen address for sentinel
redis_sentinel_port | **26379** | port for listen address
redis_sentinel_logdir | **'{{ redis_server_logdir }}'** | logdir path for sentinel
redis_sentinel_logfile | **'redis-sentinel_{{ redis_sentinel_port }}.log'** | sentinel logfile
redis_sentinel_databases_dir | **'{{ redis_server_databases_dir }}'** | sentinel database directory
redis_sentinel_quorum | **2** | redis sentinel quorum
redis sentinel downafter | **10000** | time for downafter
redis_sentinel_failover_timeout | **30000** | failover timeout
All other redis parameters have default values .
Custom configuration should be declared inside a redis_conf dictionnary (see example below)
## :arrows_counterclockwise: Dependencies
community.general >= 2.0.0
## :pencil2: Example Playbook
* #### Standalone scenario
```yaml
---
- hosts: all
roles:
- role: claranet.redis
```
* #### Previous release scenario
```yaml
---
- hosts: all
vars:
redis_server_version: "6:7.0"
roles:
- role: claranet.redis
```
* #### Password scenario
```yaml
---
- hosts: all
vars:
redis_server_password: "foobar"
roles:
- role: claranet.redis
```
* #### Custom configuration scenario
```yaml
---
- hosts: all
vars:
redis_conf:
loglevel: "warning"
roles:
- role: claranet.redis
```
The available parameters for each release of redis can be found in the self documented configuration files available [here](https://redis.io/docs/management/config/)
* #### Multi-instance scenario
```yaml
---
- name: First instance
hosts: all
vars:
redis_server_version: "6:7.0.7"
roles:
- role: claranet.redis
- name: Second instance
hosts: all
vars:
redis_server_version: "6:7.0.7"
redis_server_port: 6378
roles:
- role: claranet.redis
```
If installing a previous release of redis, both instances should be the same version
* #### Master slave scenario
**inventory**
```yaml
---
all:
children:
redis:
hosts:
master:
redis_role: master
slave-01:
redis_role: replica
slave-02:
redis_role: replica
```
**playbook**
```yaml
---
- hosts: all
roles:
- role: claranet.redis
```
* #### Sentinel scenario
**inventory**
```yaml
---
all:
children:
redis:
hosts:
master:
redis_role: master
slave-01:
redis_role: replica
slave-02:
redis_role: replica
```
**playbook**
```yaml
---
- hosts: all
vars:
redis_sentinel_enabled: true
roles:
- role: claranet.redis
```
## :closed_lock_with_key: [Hardening](HARDENING.md)
## :heart_eyes_cat: [Contributing](CONTRIBUTING.md)
## :copyright: [License](LICENSE)
[Mozilla Public License Version 2.0](https://www.mozilla.org/en-US/MPL/2.0/)