Code Monkey home page Code Monkey logo

redis_role's Introduction

Logo

Redis Ansible role

Build Status Ansible Galaxy

This Ansible role installs Redis server in a Debian environment.

Getting Started

These instructions will get you a copy of the role for your Ansible playbook. Once launched, it will install a Redis server.

Prerequisities

Ansible 2.9.x.x version installed. Inventory destination should be a Debian environment.

For testing purposes, Molecule with Docker as driver.

Installing

Create or add to your roles dependency file (e.g requirements.yml):

- src: idealista.redis_role
  version: 4.0.3
  name: redis

Install the role with ansible-galaxy command:

ansible-galaxy install -p roles -r requirements.yml -f

Use in a playbook:

- hosts: someserver
  roles:
    - redis

Usage

ATTENTION since version 5.0.0 we have introduced authentication and it is important to use two variables:

  • redis_auth which is mandatory to have a value (true/false)
  • redis_password which defines the password that will be set, remember to put it in the vault so that it is not left unencrypted (it must be 30 characters, with numbers, upper and lower case)

IF THESE VARIABLES ARE NOT CORRECTLY CONFIGURED, THE ROLE INSTALLATION WILL FAIL WITH AN EXPLANATORY MESSAGE.

Look to the defaults properties file to see the possible configuration properties.

Note: It's recommended to use Prometheus Redis Exporter Role if Prometheus monitoring is needed.

Testing

Install dependencies

$ pipenv sync

For more information read the pipenv docs.

Testing single mode

$ pipenv run molecule test -s single

Testing cluster mode

$ pipenv run molecule test -s cluster

Built With

Ansible Molecule Goss

Versioning

For the versions available, see the tags on this repository.

Additionaly you can see what change in each version in the CHANGELOG.md file.

Authors

See also the list of contributors who participated in this project.

License

Apache 2.0 License

This project is licensed under the Apache 2.0 license - see the LICENSE file for details.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

redis_role's People

Contributors

blalop avatar caldito avatar dortegau avatar jdvr avatar jmonterrubio avatar lihiwish avatar ommarmol avatar sorobon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redis_role's Issues

Improve tests in cluster-mode

As seen in #38, cluster-mode tests are should add, at least, check whether the cluster config file is present or not. Any other improvements or suggestions are welcome.

The `redis.conf` file is generated with bad indentation

include /redis/redis.conf

            cluster-config-file node.conf
            appendonly yes
            stop-writes-on-bgsave-error yes
            dbfilename dump.rdb
            loglevel notice
            bind 0.0.0.0
            slave-read-only yes
            protected-mode no
            cluster-enabled yes
            slave-serve-stale-data yes
            port 6379
            appendfilename appendonly-db.aof
            cluster-node-timeout 2000
            daemonize yes
            supervised systemd
            rdbchecksum yes
            databases 16
            logfile /var/log/redis/redis.log
            rdbcompression yes
            maxmemory 2gb
            pidfile /conf/redis/redis.pid
    
    save 900 1
    save 300 10
    save 60 10000


dir /conf/redis

Redis Gem installed version is always latest

Prerequisites

Description

As Redis Version is configurable, Redis Gem Version should be configurable too:

https://github.com/idealista/redis-role/blob/a8bdefcc56f13d7c74ecfe572f7fbe0d44cdf1f6/tasks/install.yml#L100

Additional Information

https://rubygems.org/gems/redis/versions

Add specific Redis Cluster assertions in tests

Prerequisites

Description

Goss tests should verify al least that $ redis-cli cluster info contains 3 master nodes. Verifying only that a PING returns a PONG doesn't implies that cluster is created.

Config files cannot be provided by playbooks

Prerequisites

Description

At the moment, redis-server.service, instance-manager.sh and redis.conf are provided by the role and there is no possibility of doing so with the playbooks. Using variables in the src argument of the task and defaulting these variables to the templates in the role doesn't break compatibility and makes user able to use their own templates.

Check nodes status on cluster creator

During role execution when host are provisioning one by one there is a problem with cluster creator.

Cluster creator task is always executed even when the rest of host are not up and the cluster can't be create.

Rename role

Prerequisites

Description

This role name is not compliant with Ansible Galaxy naming.
We must rename to redis_role.

[FEATURE] Add support for configuring clusters based on hostnames

Prerequisites

Description

This role configures the cluster using the IP addresses of the nodes. However, since this role installs Redis version 7.2.3 by default, and given that Redis release 7.0 introduced support for using hostnames during cluster creation, it would be great to have an option for creating clusters using hostnames.

Expected behavior: The cluster can be created using the hostnames of the nodes.
Actual behavior: The cluster can only be created using the IP addresses of the nodes.

Additional info

You could refer to the cluster-announce-hostname option introduced in Redis 7.0, as documented on redis.io.

Versions

All

[BUG] Redis role creates a home for redis user that does not seems to be necessary

Description

When creating the redis user, the createhome: false is not provided, so a home dir is created and it seems to be not necessary.

Steps to Reproduce

  1. Run role

Expected behavior:
Do not create a home for redis user
Actual behavior:
Creates a home for redis user

Reproduces how often:
Always

Environment

  • The release version/s you are using:
    4.0.3 role version, using Pipfile provided versions

Additional Information

N/A

Use j2 template to improve test

Goss validation file has a lot of content that depends on role configuration, so, change a config will break the validation even when the role has been successfully create.

Using j2 we can create redis.yml.j2 file that use playbook vars to define validation and during "verifier.yml" execution we can parse that templates and then copy to container to run the validation

Cannot execute this role under Python 3.x

Prerequisites

Description

This role cannot be executed under Python 3.x.

It fails raising an AnsibleUndefinedVariable error when is copying redis-server:

TASK [redis : REDIS | Copy server config] **************************************
fatal: [instance1]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 'iteritems'"}

Steps to Reproduce

  1. Create a Playbook using this role as requirement
  2. Create a test using vagrant
  3. Execute tests using Python 3.x

Expected behavior: It should works with Python2 and Python3

Actual behavior: Fails when server config template is copied

Reproduces how often: 100% when Python 3 is used

Versions

All

Additional Information

These recommendations should be followed: https://docs.ansible.com/ansible/2.5/user_guide/playbooks_python_version.html

Role doesn't reload new configs

Prerequisites

Description

After updating redis configs, the role doesn't notify restarting service in order to get the new configurations.
[Description of the issue]

Steps to Reproduce

  1. Modify redis parameters
  2. Run the playbook

Expected behavior: [What you expect to happen]
Service is restarted.

Actual behavior: [What actually happens]
Config changed, but service is not restarted.

Reproduces how often: [What percentage of the time does it reproduce?]
Always.

Versions

The version/s you notice the behavior.
4.x

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

Redis 5 support

Prerequisites

Description

redis-trib.rb is missing in Redis 5, all the functions where moved to redis-cli

Steps to Reproduce

  1. Try to run redis-trib.rb.

Expected behavior:
Redis cluster operations are executed.
Actual behavior:
Command doesn't exist.
Reproduces how often:
Always.

Versions

All.

Update molecule configs

Prerequisites

Description

In the latest versions of molecule (2.22) create.yml and destroy.yml are no longer needed.
We can safely remove them, moving cluster network configurations to molecule.yml

Versions

All.

Ensure that redis can read/write the pid file

Change redis-server.service.j2 to include a ExecStartPre where we make sure that redis user is able to read and write redis_confs.pidfile

Example:

ExecStartPre=/bin/mkdir -p /var/run/foo && /bin/chown user:group /var/run/foo

This issue is a bug, but according to this it shouldn't affect to redis.

Redis cluster creator script is not reliable

Prerequisites

Description

It returns 0 exit code when script fails and Ansible can't detect errors:

root@redistest1:/conf/redis# ./cluster-creator.sh 
Could not connect to Redis at redistest2:6379: Name or service not known
Could not connect to Redis at redistest3:6379: Name or service not known
Could not connect to Redis at redistest4:6379: Name or service not known
Could not connect to Redis at redistest5:6379: Name or service not known
Could not connect to Redis at redistest6:6379: Name or service not known
Waiting nodes...
root@redistest1:/conf/redis# echo $?
0

Steps to Reproduce

  1. Launch this role with --destroy never option
  2. Log in first node (using $ molecule login or docker exec)
  3. Edit and add fake hosts in /conf/redis/cluster-config.sh
  4. Launch cluster-creator script
  5. Verify that this script exits with 0 exit code

Expected behavior: I expect this script to tell that execution failed

Actual behavior: It returns 0 exit code

Reproduces how often: 100%

Versions

All

Additional Information

Any additional information, configuration or data that might be necessary to reproduce the issue.

Add the option to create redis without running redis-trib

In https://github.com/idealista/redis-role/blob/master/templates/cluster-creator.sh.j2#L41, redis-trib connect to the provided IPs and configures the redis-clusters.
The IPs are provided from the play_hosts, meaning the IPs of all of the hosts in which the play occurs. This means that for each host, redis-trib will run.
This causes deadlock, since each hosts in trying to be the "first" node on the cluster, while it waits for the other clusters to join.

Therefore, when running the role on multiple hosts within one play, redis-trib should run only once for the all of the hosts in the play.

Manage Redis cluster restart on upgrade

Create a few task that manage the upgrade of all nodes of a given cluster, the task should:

if a node is slave:

  1. Stop
  2. Upgrade
  3. Restart

if node is a master without slave:

  1. Rebalance node using weight 0.0 (this is similar to reshard removing all slots)
  2. Delete node from cluster
  3. Stop
  4. Upgrade
  5. Start
  6. Add to cluster again
  7. Rebalance

if node is a master with slave:

  1. Manual failover
  2. Stop
  3. Upgrade
  4. Start

I have commented on this issues one of the problem if I don't follow the step describe above

Yamllint does not ignore the folders that is supposed to ignore

Prerequisites

Description

Yamllint does not ignore the folders that is supposed to ignore

Steps to Reproduce

  1. add 2 blank lines in molecule/single/playbook.yml the following
  2. Launch molecule tests with molecule test -s single

Expected behavior: The linter does not complain about the blank lines in molecule.yml

Actual behavior: The linter complains about the blank lines in molecule.yml

Reproduces how often: 100%

Versions

All

redis-server.service file missing RuntimeDirectory

Prerequisites

Description

RuntimeDirectory missing could make Redis enter in an unstable state after host reboot, due to possible inability to create the PID directory.

Steps to Reproduce

  1. Use the role to install Redis
  2. Reboot the host
  3. Watch the logs. Every 2 minutes or so, Redis gets restarted via SIGTERM.

Expected behavior:

Redis to be stable after any service or host reboot.

Actual behavior:

Redis could enter in an unstable state, making the cluster unusable.

Reproduces how often:

Not verified

Versions

At least, using Redis 4.0.1 and redis-role 2.1.3

Cannot install redis in debian/stretch64 (Failed to find required executable make)

Prerequisites

Description

Ansible playbook fails when tries to install redis (in 'single' mode):

TASK [redis : REDIS | Make] ****************************************************
fatal: [redisapi5]: FAILED! => {"changed": false, "msg": "Failed to find required executable make in paths: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}

Steps to Reproduce

  1. Create a playbook
  2. Add tests using Vagrant and debian/stretch64 box
  3. Try to install this role using default vars

Expected behavior: Source files should be compiled

Actual behavior: Cannot compile source files because it fails finding required executable "make"

Reproduces how often: 100%

Versions

all

Additional Information

Vagrant Box used: https://app.vagrantup.com/debian/boxes/stretch64

[FEATURE] Add support to manage persistence

Prerequisites

Description

Currently, the role manages the server conf path but not the database one, even though it offers support for configuring RDB persistence. No database paths are managed, so the dump.rdb file ends up being dumped inside the path defined by the redis_conf_path variable. It would be great to add support for managing the paths intended for storing the dump.rdb files.

Expected behavior: By default, the /var/lib/redis path should be automatically created and used to store the dump.rdb file.
Actual behavior: By default, the dump.rdb file is dumped inside /usr/local/etc/redis path, which is not the most suitable path for storing it.

Versions

All

Add support for Redis Sentinel 2

Prerequisites

Description

In order to support Redis Sentinel 2 (https://redis.io/topics/sentinel)

Expected behavior: I expect to deploy a Redis Sentinel to provide high availability

Actual behavior: Redis Sentinel cannot be installed using this role

Versions

All

Add redis cluster tests to Travis

Prerequisites

Description

Redis installation in cluster mode is not currently tested:

https://github.com/idealista/redis-role/blob/9e2bfa2cdbccf50c7ac197473f62ba8e35e8634c/.travis.yml#L11

Versions

All

Add support to install a Redis Cluster

What configurations would be necessary:

  • mode
  • redis version
  • ports
  • timeout
  • nodes
  • replicas

Installation details that would be appreciate:

  • use supervisord to manage reboots and restarts
  • leave a "create-cluster" script in redis home directory after installing to make easy cluster management

The "create-cluster" script is specific for 6 nodes with one replica, the idea is to use the configuration defined on the role on a similar script that allows to create/start/stop the cluster easily after the machine has been provisioned.

[FEATURE] Add support for authentication

Prerequisites

Description

It would be great if some mechanism for authentication were provided, such as the requirepass option in the redis.conf file.

Expected behavior: I expect to be able to configure password authentication when deploying a redis server using this role.
Actual behavior: The Redis server is always deployed without authentication.

Versions

All

failing master during cluster upgrading

The upgrading-helper.sh is restarting the node without running the failover.

This could be a critical issue because during whole redis upgrade process the cluster is up with a failing master.

Convert 'make test' task in an optional Ansible task

Prerequisites

Description

As it takes zillion of seconds to execute Ansible Make test task (which executes 'make test' in order to check if redis build works correctly), I suggest to convert that task in optional and disabled by default.

Additional Information

https://redis.io/topics/quickstart

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.