Giter Club home page Giter Club logo

ansible-role-redis's People

Contributors

aogereau avatar bngameni avatar eliedeloumeau avatar

Stargazers

 avatar

Watchers

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

Forkers

poil muraliv21

ansible-role-redis's Issues

[BUG] Dependency errors when installing older versions of Redis

Expected Behavior

redis install should work for versions older than 7.2.0-1rl1 (current main release)

Current Behavior

When installing redis or redis-sentinel, "Install redis packages" task will try to install newer versions of the dependencies (redis-server and redis-tools) , and thus fail

fatal: [host]: FAILED! => {
    "cache_update_time": 1693313799,
    "cache_updated": true,
    "changed": false,
    "rc": 100
}
STDOUT:
Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
 redis : Depends: redis-server (< 6:7.0.12-1rl1~jammy1.1~) but 6:7.2.0-1rl1~jammy1 is to be installed
 redis-sentinel : Depends: redis-tools (= 6:7.0.12-1rl1~jammy1) but 6:7.2.0-1rl1~jammy1 is to be installed
STDERR:
W: --force-yes is deprecated, use one of the options starting with --allow instead.
E: Unable to correct problems, you have held broken packages.
MSG:
'/usr/bin/apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold"   --force-yes    install 'redis=6:7.0.12*' 'redis-sentinel=6:7.0.12*'' failed: W: --force-yes is deprecated, use one of the options starting with --allow instead.
E: Unable to correct problems, you have held broken packages.

Possible Solutions

A first solution would be to manually install the following dependencies , to be declared in the task "Specify version of packages when it's defined":
redis-tools{{ _redis_server_version_format }} when installing redis server and sentinel
redis-server{{ _redis_server_version_format }} only when installing redis server

which would translate in the debian-family.yml playbook (lines 29 to 36) :

- name: Specify version of packages when it's defined
  ansible.builtin.set_fact:
    _redis_packages_list: >-
      {%- if redis_sentinel_enabled -%}
        redis{{ _redis_server_version_format }}, redis-sentinel{{ _redis_sentinel_version_format }},  redis-server{{ _redis_server_version_format }},  redis-tools{{ _redis_server_version_format }}
      {%- else -%}
        redis{{ _redis_server_version_format }},  redis-server{{ _redis_server_version_format }},  redis-tools{{ _redis_server_version_format }}
      {%- endif -%}

a second solution would be to rework the role to follow the install from source documentation : https://redis.io/docs/getting-started/installation/install-redis-from-source/
when installing main, it should get the package https://download.redis.io/redis-stable.tar.gz
when installing older version, it should take the appropriate one form the release list : https://download.redis.io/releases/redis-{{ redis_server_version }}.tar.gz
it will install redis server and sentinel binaries, and would require a rework of the templates as for instance binaries are now in the /usr/local/bin directory

root@7f46c3ad7117:/redis-7.0.12# ll /usr/local/bin
total 22092
drwxr-xr-x 1 root root     4096 Aug 30 07:30 ./
drwxr-xr-x 1 root root     4096 Aug  4 02:02 ../
-rwxr-xr-x 1 root root  5509624 Aug 30 07:30 redis-benchmark*
lrwxrwxrwx 1 root root       12 Aug 30 07:30 redis-check-aof -> redis-server*
lrwxrwxrwx 1 root root       12 Aug 30 07:30 redis-check-rdb -> redis-server*
-rwxr-xr-x 1 root root  5392528 Aug 30 07:30 redis-cli*
lrwxrwxrwx 1 root root       12 Aug 30 07:30 redis-sentinel -> redis-server*
-rwxr-xr-x 1 root root 11698776 Aug 30 07:30 redis-server*

root@7f46c3ad7117:/redis-7.0.12# redis-
redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli        redis-sentinel   redis-server

Also the following packages should be present to build from source : make pkg-config gcc

Steps to Reproduce (for bugs)

tested with Ubuntu Jammy, Ubuntu Focal and Debian Bookworm

in terminal :

update apt cache
apt update
install required packages:
apt install lsb-release curl gpg sudo
add gpg key:
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
add redis repo:
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
update cache again
apt update
try to install an older version of Redis (7.0.12 and below)
apt install redis=6:7.0.12*

in ansible :

when setting up your variables, set redis_server_version to something other than the main release

both should give you the dependency error above

Context

Need to install Redis 7.0 for dependency reasons

Your Environment

  • Version used: 1.0.4
  • Operating System : Tested with Ubuntu Jammy, Ubuntu Focal and Debian Bookworm , all three present dependency errors

redis services still running during first deployment, preventing the start of new instances

Expected Behavior

Services redis-server@$PORT and redis-sentinel@$PORT able to start during first deployment

Current Behavior

services are unable to start because default redis-server and redis-sentinel systemd services are still runing despite being masked, preventing the launch

Redis server :

x [email protected] - Advanced key-value store
     Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: enabled)
     **Active: failed** (Result: exit-code) since Thu 2023-08-31 11:25:23 CEST; 6min ago
       Docs: http://redis.io/documentation,
             man:redis-server(1)
    Process: 11638 ExecStart=/usr/bin/redis-server /etc/redis/redis_6379.conf (code=exited, status=1/FAILURE)
   Main PID: 11638 (code=exited, status=1/FAILURE)
     Status: "Redis is loading..."
        CPU: 39ms

logs:

root@vmltestb2c0231 /var/log/redis # cat redis-server_6379.log
11622:C 31 Aug 2023 11:25:21.915 * Supervised by systemd. Please make sure you set appropriate values for TimeoutStartSec and TimeoutStopSec in your service unit.
11622:C 31 Aug 2023 11:25:21.915 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
11622:C 31 Aug 2023 11:25:21.915 # Redis version=7.0.12, bits=64, commit=00000000, modified=0, pid=11622, just started
11622:C 31 Aug 2023 11:25:21.915 # Configuration loaded
11622:M 31 Aug 2023 11:25:21.916 * monotonic clock: POSIX clock_gettime
11622:M 31 Aug 2023 11:25:21.916 # **Warning: Could not create server TCP listening socket 0.0.0.0:6379: bind: Address already in use**
root@vmltestb2c0231 /var/log/redis # systemctl status redis-server
* redis-server.service
     Loaded: masked (Reason: Unit redis-server.service is masked.)
     **Active: active (running)** since Thu 2023-08-31 11:25:11 CEST; 2min 24s ag

Redis sentinel :

* [email protected] - Advanced key-value store
     Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: enabled)
     **Active: activating (start)** since Thu 2023-08-31 12:36:58 CEST; 1min 10s ago
       Docs: http://redis.io/documentation,
             man:redis-sentinel(1)
    Process: 41941 ExecStart=/usr/bin/redis-sentinel /etc/redis/sentinel_26379.conf (code=exited, status=0/SUCCESS)

logs:

root@vmltestb2c0231 ~ # cat /var/log/redis/redis-sentinel_26379.log
36676:X 31 Aug 2023 11:59:16.339 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
36676:X 31 Aug 2023 11:59:16.340 # Redis version=7.0.12, bits=64, commit=00000000, modified=0, pid=36676, just started
36676:X 31 Aug 2023 11:59:16.340 # Configuration loaded
36676:X 31 Aug 2023 11:59:16.340 * monotonic clock: POSIX clock_gettime
36676:X 31 Aug 2023 11:59:16.340 # Warning: Could not create server TCP listening socket 0.0.0.0:26379: bind: Address already in use
root@vmltestb2c0231 ~ # systemctl status redis-sentinel.service
* redis-sentinel.service
     Loaded: masked (Reason: Unit redis-sentinel.service is masked.)
     **Active: active (running)** since Thu 2023-08-31 11:25:11 CEST; 1h 6min ago
   Main PID: 11101 (redis-sentinel)
     Status: "Ready to accept connections"
        CPU: 8.968s
     CGroup: /system.slice/redis-sentinel.service
             `-11101 "/usr/bin/redis-sentinel *:26379 [sentinel]" "" "" "" "" "" ""

Possible Solution

add a task to make sure redis-server and redis-sentinel services are stopped before masking them

in server.yml , before line 10 , task Server | Mask redis-server service :

- name: Server | Stop Redis-server service 
  ansible.builtin.systemd:
    name: redis-server.service
    state: stopped
  register: _redis_server_systemctl_start

and in sentinel.yml , before line 2 , task Sentinel | Mask redis-sentinel service :

- name: Server | Stop Redis-sentinel service 
  ansible.builtin.systemd:
    name: redis-sentinel.service
    state: stopped
  register: _redis_server_systemctl_start

Steps to Reproduce (for bugs)

Try to install redis server and or redis sentinel on a virtual machine instead of using Molecule

After install , both default services are running and enabled by default

root@ubuntu:~# systemctl status redis-se*
● redis-server.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/redis-server.service; disabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-08-31 11:17:58 UTC; 12s ago
       Docs: http://redis.io/documentation,
             man:redis-server(1)
   Main PID: 2804 (redis-server)
     Status: "Ready to accept connections"
      Tasks: 5 (limit: 4515)
     Memory: 3.0M
        CPU: 91ms
     CGroup: /system.slice/redis-server.service
             └─2804 "/usr/bin/redis-server 127.0.0.1:6379" "" "" "" "" "" "" ""

Aug 31 11:17:58 ubuntu systemd[1]: Starting Advanced key-value store...
Aug 31 11:17:58 ubuntu systemd[1]: Started Advanced key-value store.

● redis-sentinel.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/redis-sentinel.service; disabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-08-31 11:17:59 UTC; 12s ago
       Docs: http://redis.io/documentation,
             man:redis-sentinel(1)
   Main PID: 2866 (redis-sentinel)
     Status: "Ready to accept connections"
      Tasks: 5 (limit: 4515)
     Memory: 2.9M
        CPU: 98ms
     CGroup: /system.slice/redis-sentinel.service
             └─2866 "/usr/bin/redis-sentinel *:26379 [sentinel]" "" "" "" "" "" ""

Context

Install Redis cluster with Sentinel on 3 virtual machines

Your Environment

  • Version used: 1.0.5
  • Operating System : Ubuntu 22.04 , redis version 7.0.12

[BUG] Reload is not applicable to redis Sentinel

Expected Behavior

redis sentinel handlers are working

Current Behavior

current handler for sentinel is reloading redis sentinel service. However it is not an applicable instruction . should it be invoked it will cause an error

fatal: [vmltestb2c0232]: FAILED! => {
    "changed": false
}
MSG:
Unable to reload service [email protected]: Failed to reload [email protected]: Job type reload is not applicable for unit [email protected].
fatal: [vmltestb2c0231]: FAILED! => {
    "changed": false

Possible Solution

Replace Redis-sentinel reload handler by a restart

Steps to Reproduce (for bugs)

did a few tests with sentinel beforehand
Did purge redis packages for new install
Handler was invoked and failed

Context

redis cluster with sentinel on 3 nodes

Your Environment

  • Version used: 1.0.6
  • Operating System and Ansible version: ubuntu 22.04

redis_role consistency for replicas

Expected Behavior

in the redis.conf template, it is indicated that the redis_role variable for all replicas should be "replica"
it should be the same value that is indicated in the Readme.md

Current Behavior

https://github.com/claranet/ansible-role-redis/blob/main/templates/etc/redis/redis.conf.j2 line 291 , replicas has redis_role = replica
https://github.com/claranet/ansible-role-redis/blob/main/README.md , lines 120 - 122 - 150 and 152 replicas have redis_role = slave
For consistency sake, the value of redis_role should be se same in both cases

Possible Solution

in Readme.md , replace bloc from lines 107 to 153 by the following :

  • Master replica scenario

inventory

---
all:
  children:
    redis:
      hosts:
        master:
          redis_role: master
        replica-01:
          redis_role: replica
        replica-02:
          redis_role: replica

playbook

---
- hosts: all
  vars:
    redis_sentinel_enabled: false
    redis_server_version: latest
  roles:
    - role: claranet.redis
  • Sentinel scenario

inventory

---
all:
  children:
    redis:
      hosts:
        master:
          redis_role: master
        replica-01:
          redis_role: replica
        replica-02:
          redis_role: replica

or , in redis.conf template , change the value of redis_role from replica to slave

{% if redis_role is defined and redis_role == "slave" %}
replicaof {{ _redis_master_ip }} {{ redis_server_port }}
{% endif %}

Context

This will cause problems when setting up a Redis cluster . If people follow the readme, the replicas will not be properly configured

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.