geerlingguy / ansible-role-redis Goto Github PK
View Code? Open in Web Editor NEWAnsible Role - Redis
Home Page: https://galaxy.ansible.com/geerlingguy/redis/
License: MIT License
Ansible Role - Redis
Home Page: https://galaxy.ansible.com/geerlingguy/redis/
License: MIT License
Either apt-get update needs to be done or,
update_cache=yes needs to be set in apt.
It seems to be a single node installation, please add support for replication.
http://redis.io/topics/replication
These items in the redis config template break under redis 2.8:
hash-max-zipmap-entries 512
hash-max-zipmap-value 64
They have been replaced with hash-max-ziplist-*
which it appears you already have in the config.
http://redis.io/topics/memory-optimization.
As the title says...
in the main inside tasks there is a include_vars: "{{ ansible_os_family }}.yml"
but i can't find this variable anywhere and indeed the deploy is failing.
where can i find it?
many thanks
When using current master 155a98cd
I get followig error:
web: Running ansible-playbook...
[WARNING]: It is unnecessary to use '{{' in loops, leave variables in loop
expressions bare.
[WARNING]: It is unnecessary to use '{{' in conditionals, leave variables in
loop expressions bare.
ERROR: check_mode is not a legal parameter in an Ansible task or handler
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
What am I doing wrong?
Do you want to support redis cluster in this role? When yes, then I can provide a pull request.
fatal: [13.127.200.142]: FAILED! => {"failed": true, "msg": "Unable to create local directories(/home/ubuntu/.ansible/cp): [Errno 13] Permission denied: '/home/ubuntu/.ansible/cp'"}
As the title says...
I'm seeing the same issue as those reported here:
bennojoy/redis#6
Shell output:
$ redis-server --version
Redis server v=2.8.4 sha=00000000:0 malloc=jemalloc-3.4.1 bits=64 build=a44a05d76f06a5d9
$ sudo redis-server /etc/redis/redis.conf
*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 34
>>> 'vm-enabled no'
Bad directive or wrong number of arguments
Add an option to install Redis from source (so users can have the latest possible version, instead of just the versions available through the default apt repos or EPEL).
Doc says:
"# Set to an empty set to disable persistence (saving the DB to disk)."
So, when setting:
redis_save: []
However, this just writes nothing about the Redis "save" settings. If for whatever reason RDB persistence is enabled by default this role won't disable it.
I have a need to run 2 redis instances on the same server.
Each would be the same, but using a different backup strategy. (Underlying requirement is a queue with sensitive data that can't get written to disk, and accepting the failure tolerance that goes with that)
Would it be possible to provision both instances using this role? Or would I be better off installing 1 (which I already have) and using Ansible file manipulation to create the second one "by hand"?
Thanks
Hi, we use this Ansible Role. So far so good but we get the following warnings when starting Redis:
#1 WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
#2 WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
#3 WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
Although these are only warnings it would be nice to have the option to fix them. This blog post describes all these warnings and gives (bash like) solutions on how to get rid of them:
I'm envisioning some new options a user could set, theoretical examples:
Here are some Ansible snippets with the same solutions as described in the blog post that could be inspiring.
Fix for 1 and 2
https://github.com/QafooLabs/redis-testing/blob/master/provision.yml
Fix for 2
https://github.com/akishin/ansible-playbooks/blob/master/gitlab-unicorn/roles/redis/tasks/main.yml
Fix for 3
There are many other examples in GitHub but no reusable Ansible role repo seems to have all of them in one place.
Thank you for your consideration.
This also applies to your other roles
redis 6.2.1 Failed with result 'protocol'
Fixed after adding "supervised auto" to templates/redis.conf.j2
OS VERSION="20.04.2 LTS (Focal Fossa)"
pre_tasks:
- name: Add chris-lea APT repositories
apt_repository:
repo: "ppa:redislabs/redis"
state: present
update_cache: yes
See title...
When using the current master (a76cee5) of ansible-role-redis, I get this error (with ansible 1.9.4):
ERROR: package is not a legal parameter in an Ansible task or handler
I reverted to tag 1.3.0 and it works again.
Maybe the master only works with ansible 2+?
Thanks for providing this role :)
Would find it very useful if this role also supported Redis Sentinel. Would you be opposed to adding that functionality?
Thanks -
John
It looks like a single instance Redis.
Using this role I found that systemctl status redis-server
would return
redis-server.service - Advanced key-value store
Loaded: loaded (/lib/systemd/system/redis-server.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2018-12-05 19:35:24 UTC; 2min 39s ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Main PID: 13355 (redis-server)
Tasks: 4 (limit: 4383)
CGroup: /system.slice/redis-server.service
`-13355 /usr/bin/redis-server 127.0.0.1:6379
In tasks/main.yml
there is the line service: "name={{ redis_daemon }} state=started enabled=yes"
which should enable the service.
To get around this I added my own task after the geerlingguy.redis
role completed:
- name: enable redis-server
systemd:
name: redis-server
enabled: yes
when: ansible_service_mgr == 'systemd'
which effectively didn't change anything.
I finally tried:
- name: Ensure redis-server is enabled
shell: systemctl enable redis-server
register: enable_result
when: ansible_service_mgr == 'systemd'
changed_when: "'Created symlink' in enable_result.stderr"
this did work with the output:
changed: [voltserv-app-04] => {
"changed": true,
"cmd": "systemctl enable redis-server",
"delta": "0:00:00.500761",
"end": "2018-12-05 19:03:05.330731",
"invocation": {
"module_args": {
"_raw_params": "systemctl enable redis-server",
"_uses_shell": true,
"argv": null,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"warn": true
}
},
"rc": 0,
"start": "2018-12-05 19:03:04.829970",
"stderr": "Synchronizing state of redis-server.service with SysV service script with /lib/systemd/systemd-sysv-install.\nExecuting: /lib/systemd/systemd-sysv-install enable redis-server\nCreated symlink /etc/systemd/system/redis.service -> /lib/systemd/system/redis-server.service.",
"stderr_lines": [
"Synchronizing state of redis-server.service with SysV service script with /lib/systemd/systemd-sysv-install.",
"Executing: /lib/systemd/systemd-sysv-install enable redis-server",
"Created symlink /etc/systemd/system/redis.service -> /lib/systemd/system/redis-server.service."
],
"stdout": "",
"stdout_lines": []
}changed: [voltserv-app-04] => {
"changed": true,
"cmd": "systemctl enable redis-server",
"delta": "0:00:00.500761",
"end": "2018-12-05 19:03:05.330731",
"invocation": {
"module_args": {
"_raw_params": "systemctl enable redis-server",
"_uses_shell": true,
"argv": null,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"stdin": null,
"warn": true
}
},
"rc": 0,
"start": "2018-12-05 19:03:04.829970",
"stderr": "Synchronizing state of redis-server.service with SysV service script with /lib/systemd/systemd-sysv-install.\nExecuting: /lib/systemd/systemd-sysv-install enable redis-server\nCreated symlink /etc/systemd/system/redis.service -> /lib/systemd/system/redis-server.service.",
"stderr_lines": [
"Synchronizing state of redis-server.service with SysV service script with /lib/systemd/systemd-sysv-install.",
"Executing: /lib/systemd/systemd-sysv-install enable redis-server",
"Created symlink /etc/systemd/system/redis.service -> /lib/systemd/system/redis-server.service."
],
"stdout": "",
"stdout_lines": []
}
I would expect that the service should be enabled to start with, and also that the initial attempt to enable would work. I wouldn't rule out user error but figured I'd submitted an issue anyway. Let me know if I can provide any other info.
- Ansible version: ansible 2.6.2
config file = None
configured module search path = [u'/Users/greggbailey/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 2.7.15 (default, Jun 17 2018, 12:46:58) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]
- Machine running ansible playbook: macOS Mojave 10.14.1
- Linux version: NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.1 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
- geerlinguy.redis: 1.6.0 (also experienced issue on 1.5.1)
As the title says...
I used this Redis role after OS hardening role which disabled all IPv6 settings in sysctl.conf
. That resulted in the failure of apt-get install redis-server
(I'm on Ubuntu server) command.
Error output is:
Reading package lists...
Building dependency tree...
Reading state information...
redis-server is already the newest version (5:4.0.9-1ubuntu0.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up redis-server (5:4.0.9-1ubuntu0.1) ...
Job for redis-server.service failed because a timeout was exceeded.
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: timeout) since Wed 2019-01-30 15:26:36 MSK; 7ms ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Jan 30 15:26:36 eps-lw-banking systemd[1]: \u001b[0;1;31m\u001b[0;1;39m\u001b[0;1;31mFailed to start Advanced key-value store.\u001b[0m
dpkg: error processing package redis-server (--configure):
installed redis-server package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
redis-server
The problem is that default redis.conf
from redis-server
package contains bind 127.0.0.1 ::1
line, so Redis tries to bind on disabled IPv6 address and hangs.
I found discussions of this problem on Ubuntu and Debian bugtrackers. I understand that this is more redis-server
package problem than the problem of this role, but it would be great if this role had a workaround for this situation.
By default, this role is configured to set bind
to 127.0.0.1
(redis_bind_interface
setting), so I found the following solution: I changed the order of Redis configuration and Redis installation tasks in the play, and I also added the task for creating the /etc/redis
dir:
- name: Ensure Redis configuration dir exists.
file:
path: "{{ redis_conf_path | dirname }}"
state: directory
mode: 0755
- name: Ensure Redis is configured.
template:
src: redis.conf.j2
dest: "{{ redis_conf_path }}"
mode: 0644
notify: restart redis
# Setup/install tasks.
- include_tasks: setup-Debian.yml
when: ansible_os_family == 'Debian'
Now, when redis-server
installation happens, the installer uses preconfigured redis.conf
and all works even if IPv6 is totally disabled.
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.
$ 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.
Hi,
i would be nice if this ansible role provide a possibility to got redis packes from the redis.io repository.
Currently Debian Std. Repo provides redis 6.0.x and debian backport 7.0.x.
On redis.io, redis is available up to 7.2.x.
Hey,
I am a little bit puzzled about the content of ansible-role-redis/tasks/setup-RedHat.yml
enablerepo: xxxx
According to https://docs.ansible.com/ansible/latest/modules/package_module.html this is not supported. Is this some undocumented behaviour or should the yum module be used, instead?
I haven't tested it, but would be interested in the behaviour.
A lot of variable can't be managed by ansible. I don't want to change them by hand, that's the point of using ansible.
As a side note, the syslog part in the template is absurd, you can't say # Ansible managed
at the top of the file and then tell the user to edit by hand.
I use my fork at the moment, I send a PR as soon as I test how redis plays with unknown conf variables. If it doesn't play well we will have to create one template per redis version. (like ANXS.postgresql role does)
Hello, I just use the role, but I'm getting an error running a Node.Js instance:
Redis server does not require a password, but a password was supplied.
which means that redis is not working:
vars:
nodejs_version: "10.x"
nodejs_npm_global_packages:
- name: pm2
redis_requirepass: "aaa..."
roles:
- geerlingguy.nodejs
- geerlingguy.redis
Hello,
I used this role to install redis on debian system.
When starting the command systemctl status redis-server
, the error message below is displayed:
May 02 21:41:46 netbox-db-dc1-01 systemd[1]: redis-server.service: Can't open PID file /run/redis/redis-server.pid
The systemd configuration file provided by the package is using /run/redis/redis-server.pid
as pid file.
The template in this project is using /var/run/redis/redis-server.pid
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.