geerlingguy / ansible-role-redis

Ansible Role - Redis
https://galaxy.ansible.com/geerlingguy/redis/
MIT License
254 stars 197 forks source link

Error when installing from official Redis repository on Ubuntu #64

Closed hussainweb closed 2 years ago

hussainweb commented 3 years ago

This happens when configuring a Ubuntu 20.04 server with the official Redis Ubuntu PPA (not the built-in one). I don't see documentation related to this method not being supported, and so I'm creating this issue. The reason I am using this repo is that Ubuntu 20.04's repo defaults to Redis 5 but I want to install Redis 6.

I set the following variables in my playbook:

---
redis_package: redis
redis_maxmemory: 512M
redis_maxmemory_policy: allkeys-lfu
redis_save: []

I have this set in my pre_tasks:

  pre_tasks:
    - name: Add repository for packages
      apt_repository:
        repo: "{{ item }}"
        state: present
      with_items:
        - ppa:redislabs/redis

I see an error during the playbook run which I can manually reproduce too. Here's the output:

Oct 31 23:58:55 localhost systemd[1]: redis-server.service: Failed with result 'protocol'.
Oct 31 23:58:55 localhost systemd[1]: Failed to start Advanced key-value store.
Full output ```bash $ apt-get install redis Reading package lists... Done Building dependency tree Reading state information... Done redis is already the newest version (6:6.2.6-1rl1~focal1). 0 upgraded, 0 newly installed, 0 to remove and 68 not upgraded. 2 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Do you want to continue? [Y/n] Y Setting up redis-server (6:6.2.6-1rl1~focal1) ... Job for redis-server.service failed because the service did not take the steps required by its unit configuration. See "systemctl status redis-server.service" and "journalctl -xe" for details. invoke-rc.d: initscript redis-server, action "start" failed. ● redis-server.service - Advanced key-value store Loaded: loaded (/lib/systemd/system/redis-server.service; disabled; vendor preset: enabled) Active: activating (auto-restart) (Result: protocol) since Sun 2021-10-31 23:58:55 UTC; 5ms ago Docs: http://redis.io/documentation, man:redis-server(1) Process: 33353 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS) Main PID: 33353 (code=exited, status=0/SUCCESS) Oct 31 23:58:55 localhost systemd[1]: redis-server.service: Failed with result 'protocol'. Oct 31 23:58:55 localhost systemd[1]: Failed to start Advanced key-value store. dpkg: error processing package redis-server (--configure): installed redis-server package post-installation script subprocess returned error exit status 1 dpkg: dependency problems prevent configuration of redis: redis depends on redis-server (<< 6:6.2.6-1rl1~focal1.1~); however: Package redis-server is not configured yet. redis depends on redis-server (>= 6:6.2.6-1rl1~focal1); however: Package redis-server is not configured yet. dpkg: error processing package redis (--configure): dependency problems - leaving unconfigured No apport report written because the error message indicates its a followup error from a previous failure. Errors were encountered while processing: redis-server redis E: Sub-process /usr/bin/dpkg returned an error code (1) ```

After searching about this, I found the configuration option supervised which is set to no by default. But this needs to be set to systemd (or auto) for it to work as a service.

Now, I am not sure why this works right now. But adding supervised auto in my redis.conf is enough to get it to run without errors. I see this setting is present since Redis 3.2, so it might be safe to set it in the template here.

hussainweb commented 3 years ago

I am now working with a workaround:

The actual is a bit more involved with variables, etc but the result is that the line is added via config. Playbook runs without errors in this case on a completely clean instance.

With this test, I am happy to create a PR by adding this line to the template and a config value. If I am missing something, please let me know. Thanks!

stale[bot] commented 2 years ago

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

stale[bot] commented 2 years ago

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

marksabbath commented 6 months ago

This happens when configuring a Ubuntu 20.04 server with the official Redis Ubuntu PPA (not the built-in one). I don't see documentation related to this method not being supported, and so I'm creating this issue. The reason I am using this repo is that Ubuntu 20.04's repo defaults to Redis 5 but I want to install Redis 6.

I set the following variables in my playbook:

---
redis_package: redis
redis_maxmemory: 512M
redis_maxmemory_policy: allkeys-lfu
redis_save: []

I have this set in my pre_tasks:

  pre_tasks:
    - name: Add repository for packages
      apt_repository:
        repo: "{{ item }}"
        state: present
      with_items:
        - ppa:redislabs/redis

I see an error during the playbook run which I can manually reproduce too. Here's the output:

Oct 31 23:58:55 localhost systemd[1]: redis-server.service: Failed with result 'protocol'.
Oct 31 23:58:55 localhost systemd[1]: Failed to start Advanced key-value store.

Full output After searching about this, I found the configuration option supervised which is set to no by default. But this needs to be set to systemd (or auto) for it to work as a service.

Now, I am not sure why this works right now. But adding supervised auto in my redis.conf is enough to get it to run without errors. I see this setting is present since Redis 3.2, so it might be safe to set it in the template here.

Use this and you'll get that solved:

    redis_extra_config: |-
      supervised auto