davidwittman / ansible-redis Goto Github PK
View Code? Open in Web Editor NEWHighly-configurable Ansible role to install Redis and Redis Sentinel from source
License: MIT License
Highly-configurable Ansible role to install Redis and Redis Sentinel from source
License: MIT License
If you use the ansible role to change the auth for a server, it will rewrite the password in the config file.
To restart, though, the generated service uses the CLI interface to run commands, with the CLI interface reading from the config file we've already overwritten, so it just fails to auth to itself, since it's using the new password while the old server is still running.
This is made worse because the service just fires the CLI message and then takes it on faith that it will work, and goes into a while
loop waiting for the pid file to disappear to declare success.
But, when there's an auth error and the server doesn't actually get the message about the restart, the restart service will block for all time.
Thanks for creating this playbook! I'm having a small problem during installation, and I'm not 100% sure if it's a problem with the package or my vagrant box, or with something I'm doing.
Here's the output I'm getting when I attempt to provision:
...
TASK: [DavidWittman.redis | install dependencies] *****************************
ok: [default] => (item=gcc,make,libc6-dev)
TASK: [DavidWittman.redis | install dependencies] *****************************
skipping: [default]
TASK: [DavidWittman.redis | enable overcommit in sysctl] **********************
failed: [default] => {"failed": true, "parsed": false}
Traceback (most recent call last):
File "/home/vagrant/.ansible/tmp/ansible-tmp-1429466343.23-73074173030441/sysctl", line 1936, in <module>
main()
File "/home/vagrant/.ansible/tmp/ansible-tmp-1429466343.23-73074173030441/sysctl", line 335, in main
result = SysctlModule(module)
File "/home/vagrant/.ansible/tmp/ansible-tmp-1429466343.23-73074173030441/sysctl", line 118, in __init__
self.process()
File "/home/vagrant/.ansible/tmp/ansible-tmp-1429466343.23-73074173030441/sysctl", line 164, in process
self.write_sysctl()
File "/home/vagrant/.ansible/tmp/ansible-tmp-1429466343.23-73074173030441/sysctl", line 302, in write_sysctl
fd, tmp_path = tempfile.mkstemp('.conf', '.ansible_m_sysctl_', os.path.dirname(self.sysctl_file))
File "/usr/lib/python2.7/tempfile.py", line 300, in mkstemp
return _mkstemp_inner(dir, prefix, suffix, flags)
File "/usr/lib/python2.7/tempfile.py", line 235, in _mkstemp_inner
fd = _os.open(file, flags, 0600)
OSError: [Errno 13] Permission denied: '/etc/.ansible_m_sysctl_lh1_3d.conf'
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/Users/ryanisnan/vagrant.retry
default : ok=7 changed=5 unreachable=0 failed=1
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
I would like to set values in the redis.config under "Advanced" such as hash-max-ziplist-entries
.
Is there a preferred method for doing that?
Would a new role variable for a redis.config file to override the default tempting solution be an option?
Thanks,
Ben
If a bind address other than localhost/0.0.0.0 is used, the Redis init scripts fail to cleanly shutdown the service. We'll need to account for this by including the bind address either in the init script itself, or in the init config file in /etc/{sysconfig,default}.
Is it possible to install server and sentinel on the same node?
I know it is not ideal but can be useful for minimalistic 3 node setup.
When you change the version number of redis, like if you want to upgrade the version is not put into work.
This is due to the following task:
- name: install redis
command: make PREFIX={{ redis_install_dir }} install
chdir=/usr/local/src/redis-{{ redis_version }}
creates={{ redis_install_dir }}/bin/redis-server
Due to the creates option, and because the redis_install_dir does not contain the redis version number, this new version is never installed, but just extracted and compiled.
Hi,
Very nice Ansible script. Good job. Thank you, it helps a lot.
However, when I run it, it hangs on the "restart redis" task, I have to stop it manually:
NOTIFIED: [rolebooks/db/redis | restart redis] ********************************
Do you have the same behavior?
When I look at the services running on the targeted machine, it seems to be ok:
vagrant@vagrant-ubuntu-trusty-64:/$ ps aux | grep redis
root 6851 0.0 0.1 4444 648 ? S 01:10 0:00 /bin/sh /etc/init.d/redis_6379 start
redis 6855 0.3 0.4 36740 2388 ? Sl 01:10 0:00 /opt/redis/bin/redis-server 127.0.0.1:6379
Here is how I used the script:
- hosts: all
sudo: yes
roles:
- {
role: rolesbooks/db/redis,
redis_version: "2.8.17",
redis_bind: "127.0.0.1",
redis_port: "6379",
redis_logfile: "{{project_dirs.logs}}/redis.log",
redis_databases: "1",
redis_daemonize: "no",
redis_maxmemory: "100mb",
redis_maxmemory_policy: "allkeys-lru",
}
Thanks.
With the addition of the task to ensure Redis is started (in 54d67ab), there's now a scenario where the Redis services could potentially be started and then immediately restarted:
When this happens, Redis is started at the end of the server.yml tasks, and then restarted later when the restart redis
handler is notified due to the config changes.
Per some feedback from halberom on #ansible, it looks like the handlers can be flushed before ensuring the service is started, which should prevent this from happening.
- meta: flush_handlers
Not an issue, but more of a call for assistance!
Is there a way with ansible-redis (I assume using Sentenial) to have a High Availability setup for Master, and with multiple slaves connecting to the active master.
So for example;
+--------+ +--------+
- M1 - <=> - S1 -
+--------+ +--------+
_ _ _ | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ \ \
+--------+ +--------+ +--------+
- C1 - - C2 - - C3 -
+--------+ +--------+ +--------+
S1 is a slave of M1, if M1 were to fail, S1 would be promoted to Master.
C1, C2, C3 are all slaves of M1 or S1 (depending which is the active master)
Thanks,
Adam
When changing the bind address of the redis the managed redis instances, ansible hangs on waiting for the service to come back up. I think that this is because the bind address is changed in the config file, then the redis service is restarted using a command based on the new bind address.
Use this awesome repo to create a redis instance bound to 127.0.0.1, then modify the playbook to bind to the machine's actual IP.
Let me know if you would like more info, or can recommend a solution that I can implement.
Since we're not running redis as root, we'll need to bump up the open file limit for the redis user. This will likely need to be set in the init script (via a variable in /etc/default) or in /etc/security/limits.conf.
Hello, i'm trying to use your role script to configure a vagrant virtual machine.
My playbook:
---
- hosts: all
user: vagrant
sudo: yes
roles:
- DavidWittman.redis
- database
Running "vagrant up" i get:
Bringing machine 'payroll' up with 'virtualbox' provider...
[payroll] Importing base box 'precise32'...
[payroll] Matching MAC address for NAT networking...
[payroll] Setting the name of the VM...
[payroll] Clearing any previously set forwarded ports...
[payroll] Clearing any previously set network interfaces...
[payroll] Preparing network interfaces based on configuration...
[payroll] Forwarding ports...
[payroll] -- 22 => 2222 (adapter 1)
[payroll] Booting VM...
[payroll] Waiting for machine to boot. This may take a few minutes...
[payroll] Machine booted and ready!
[payroll] The guest additions on this VM do not match the installed version of
VirtualBox! In most cases this is fine, but in rare cases it can
prevent things such as shared folders from working properly. If you see
shared folder errors, please make sure the guest additions within the
virtual machine match the version of VirtualBox you have installed on
your host and reload your VM.
Guest Additions Version: 4.2.0
VirtualBox Version: 4.3
[payroll] Configuring and enabling network interfaces...
[payroll] Mounting shared folders...
[payroll] -- /vagrant
[payroll] Running provisioner: ansible...
PLAY [all] ********************************************************************
GATHERING FACTS ***************************************************************
ok: [payroll]
TASK: [DavidWittman.redis | install dependencies] *****************************
changed: [payroll] => (item=gcc,make,libc6-dev)
TASK: [DavidWittman.redis | install dependencies] *****************************
skipping: [payroll]
TASK: [DavidWittman.redis | enable overcommit in sysctl] **********************
changed: [payroll]
TASK: [DavidWittman.redis | add redis user] ***********************************
changed: [payroll]
TASK: [DavidWittman.redis | download redis] ***********************************
changed: [payroll]
TASK: [DavidWittman.redis | upload redis] *************************************
skipping: [payroll]
TASK: [DavidWittman.redis | extract redis tarball] ****************************
changed: [payroll]
TASK: [DavidWittman.redis | compile redis] ************************************
changed: [payroll]
TASK: [DavidWittman.redis | create redis install directory] *******************
ok: [payroll]
TASK: [DavidWittman.redis | create /etc/redis] ********************************
changed: [payroll]
TASK: [DavidWittman.redis | create /var/run/redis] ****************************
changed: [payroll]
TASK: [DavidWittman.redis | install redis] ************************************
changed: [payroll]
TASK: [DavidWittman.redis | list redis binaries] ******************************
ok: [payroll]
TASK: [DavidWittman.redis | add redis binaries to alternatives] ***************
failed: [payroll] => (item=redis-benchmark) => {"failed": true, "item": "redis-benchmark", "parsed": false}
SUDO-SUCCESS-ukekmrntwbssexuzjesgrgrsnvxovkqg
Traceback (most recent call last):
File "/home/vagrant/.ansible/tmp/ansible-tmp-1424885715.08-274944950675321/alternatives", line 1723, in <module>
main()
File "/home/vagrant/.ansible/tmp/ansible-tmp-1424885715.08-274944950675321/alternatives", line 126, in main
line_name, line_mode, line_path = line.strip().split("\t")
ValueError: need more than 1 value to unpack
failed: [payroll] => (item=redis-check-aof) => {"failed": true, "item": "redis-check-aof", "parsed": false}
SUDO-SUCCESS-herdhrmjwuehyatkopuplogtywaosaph
Traceback (most recent call last):
File "/home/vagrant/.ansible/tmp/ansible-tmp-1424885715.27-64895011136970/alternatives", line 1723, in <module>
main()
File "/home/vagrant/.ansible/tmp/ansible-tmp-1424885715.27-64895011136970/alternatives", line 126, in main
line_name, line_mode, line_path = line.strip().split("\t")
ValueError: need more than 1 value to unpack
failed: [payroll] => (item=redis-check-dump) => {"failed": true, "item": "redis-check-dump", "parsed": false}
SUDO-SUCCESS-fyqfxpjfoeilddbqlthcosdoejjphyhf
Traceback (most recent call last):
File "/home/vagrant/.ansible/tmp/ansible-tmp-1424885715.45-51532570914849/alternatives", line 1723, in <module>
main()
File "/home/vagrant/.ansible/tmp/ansible-tmp-1424885715.45-51532570914849/alternatives", line 126, in main
line_name, line_mode, line_path = line.strip().split("\t")
ValueError: need more than 1 value to unpack
failed: [payroll] => (item=redis-cli) => {"failed": true, "item": "redis-cli", "parsed": false}
SUDO-SUCCESS-htrsqivxvwgfilfataujadaqqxdrhieq
Traceback (most recent call last):
File "/home/vagrant/.ansible/tmp/ansible-tmp-1424885715.61-128316913027241/alternatives", line 1723, in <module>
main()
File "/home/vagrant/.ansible/tmp/ansible-tmp-1424885715.61-128316913027241/alternatives", line 126, in main
line_name, line_mode, line_path = line.strip().split("\t")
ValueError: need more than 1 value to unpack
failed: [payroll] => (item=redis-server) => {"failed": true, "item": "redis-server", "parsed": false}
SUDO-SUCCESS-uvahlwknzeuzpxrpwchvuooglmchmefi
Traceback (most recent call last):
File "/home/vagrant/.ansible/tmp/ansible-tmp-1424885715.79-139109903766318/alternatives", line 1723, in <module>
main()
File "/home/vagrant/.ansible/tmp/ansible-tmp-1424885715.79-139109903766318/alternatives", line 126, in main
line_name, line_mode, line_path = line.strip().split("\t")
ValueError: need more than 1 value to unpack
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/home/menegazzo/playbook.retry
payroll : ok=12 changed=9 unreachable=0 failed=1
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
Seems to be an issue with ansible, but i have no idea where to start.
Any tips will be welcome.
As far as I can tell, both redis-cli
and redis-server
aren't symlinked to /usr/bin
during install. Is there any reasoning behind this?
It would be very useful to have the ability to see the Redis service(s) status via service status
.
I guess we could use:
status_of_proc
via /lib/lsb/init-functions
status
via /etc/init.d/functions
Happy to have a crack at it but as it's non-trivial I thought I'd raise an issue to capture the requirement π
Hi,
A newbie question but in the config files there's no "cluster-enabled yes" setting so redis-cli> cluster commands, like "cluster nodes" gives: "ERR This instance has cluster support disabled". How should I overcome this?
Thank you,
Balazs
You fool.
When adding the following properties to the vars/main.yml and including the file in the main.yml that
i.e.
vars_files:
vars/main.yml
tasks:
include: tasks/master.yml
and using the DavidWittman.redis role
i.e.
name: "Configure the master redis server."
hosts: redis-master
roles:
DavidWittman.redis
sudo: yes
The following properties in vars/main.yml do not seem to have an effect on the redis configuration file:
redis_password: somePasswordThatYouWillNeverGUessBecauseItIsSoExcruciatinglyLong
redis_logfile: '/var/log/redis.log'
Which look like the following after the Ansible run is compete.
logfile ""
Sorry the markdown is interfering with the code above but you should get the gist of it!
I think there might be missing dependencies that prevent redis from compiling. I setup a new debian wheezy instance and redis was the first thing on my list to install, it crashed when trying to compile it which is listed below.
After installing: postgres, nodejs and ruby then redis was able to compile but only after I manually deleted the src/redis folder because the role wasn't able to recover.
GATHERING FACTS ***************************************************************
ok: [teststack]
TASK: [DavidWittman.redis | install dependencies] *****************************
changed: [teststack] => (item=gcc,make)
TASK: [DavidWittman.redis | install dependencies] *****************************
skipping: [teststack]
TASK: [DavidWittman.redis | enable overcommit in sysctl] **********************
changed: [teststack]
TASK: [DavidWittman.redis | add redis user] ***********************************
changed: [teststack]
TASK: [DavidWittman.redis | download redis] ***********************************
changed: [teststack]
TASK: [DavidWittman.redis | extract redis tarball] ****************************
changed: [teststack]
TASK: [DavidWittman.redis | compile redis] ************************************
failed: [teststack] => {"changed": true, "cmd": ["make", "-j5"], "delta": "0:00:00.841175", "end": "2014-08-02 05:49:29.803057", "rc": 2, "start": "2014-08-02 05:49:28.961882"}
stderr: lapi.c:8:20: fatal error: assert.h: No such file or directory
compilation terminated.
lcode.c:8:20: fatal error: stdlib.h: No such file or directory
compilation terminated.
linenoise.c:97:21: fatal error: termios.h: No such file or directory
compilation terminated.
net.c:34:23: fatal error: sys/types.h: No such file or directory
compilation terminated.
make[3]: *** [lapi.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [net.o] Error 1
make[3]: *** Waiting for unfinished jobs....
hiredis.c:33:20: fatal error: string.h: No such file or directory
compilation terminated.
make[3]: *** [lcode.o] Error 1
make[2]: *** [lua] Error 2
make[2]: *** Waiting for unfinished jobs....
make[3]: *** [linenoise.o] Error 1
make[2]: *** [linenoise] Error 2
make[3]: *** [hiredis.o] Error 1
make[2]: *** [hiredis] Error 2
configure: error: in `/usr/local/src/redis-2.8.9/deps/jemalloc':
configure: error: C compiler cannot create executables
See `config.log' for more details
make[2]: *** [jemalloc] Error 77
make[1]: [persist-settings] Error 2 (ignored)
CC adlist.o
CC ae.o
CC anet.o
CC dict.o
anet.c:33:23: fatal error: sys/types.h: No such file or directory CC redis.o
ae.c:33:19: fatal error: stdio.h: No such file or directory
compilation terminated.
adlist.c:32:20: fatal error: stdlib.h: No such file or directory
compilation terminated.
dict.c:38:19: fatal error: stdio.h: No such file or directory
compilation terminated.
compilation terminated.
In file included from redis.h:34:0,
from redis.c:30:
config.h:89:27: fatal error: linux/version.h: No such file or directory
compilation terminated.
make[1]: *** [anet.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [ae.o] Error 1
make[1]: *** [dict.o] Error 1
make[1]: *** [adlist.o] Error 1
make[1]: *** [redis.o] Error 1
make: *** [all] Error 2
stdout: cd src && make all
make[1]: Entering directory `/usr/local/src/redis-2.8.9/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[2]: Entering directory `/usr/local/src/redis-2.8.9/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/usr/local/src/redis-2.8.9/deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic >> .make-settings
echo WARN=-Wall >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -Wall -O2 -g -ggdb -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS= -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua jemalloc)
make[2]: Entering directory `/usr/local/src/redis-2.8.9/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-ldflags)
(echo "" > .make-cflags)
MAKE hiredis
MAKE linenoise
cd hiredis && make static
MAKE lua
cd linenoise && make
cd lua/src && make all CFLAGS="-O2 -Wall -DLUA_ANSI " MYLDFLAGS=""
MAKE jemalloc
make[3]: Entering directory `/usr/local/src/redis-2.8.9/deps/linenoise'
cd jemalloc && ./configure --with-jemalloc-prefix=je_ --enable-cc-silence CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops " LDFLAGS=""
cc -Wall -Os -g -c linenoise.c
make[3]: Entering directory `/usr/local/src/redis-2.8.9/deps/lua/src'
cc -O2 -Wall -DLUA_ANSI -c -o lapi.o lapi.c
cc -O2 -Wall -DLUA_ANSI -c -o lcode.o lcode.c
make[3]: Entering directory `/usr/local/src/redis-2.8.9/deps/hiredis'
cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb hiredis.c
make[3]: Leaving directory `/usr/local/src/redis-2.8.9/deps/lua/src'
make[3]: Leaving directory `/usr/local/src/redis-2.8.9/deps/linenoise'
make[3]: Leaving directory `/usr/local/src/redis-2.8.9/deps/hiredis'
checking for xsltproc... no
checking for gcc... gcc
checking whether the C compiler works... no
make[2]: Leaving directory `/usr/local/src/redis-2.8.9/deps'
make[1]: Leaving directory `/usr/local/src/redis-2.8.9/src'
FATAL: all hosts have already failed -- aborting
hi:
If i want to deploy 32 instances redis, and i have to write 32 times "redis_port"
how can i combine that such as
redis_port: 2000-2031
when parameter
redis_daemonize: no
it causes
daemonize False
available values are yes or no ;
'daemonize False'
argument must be 'yes' or 'no'
When the role tries to start the redis service, I get this error:
[/etc/systemd/system/redis_6379.service:10] Executable path is not absolute, ignoring: "/opt/redis/bin/redis-server" /etc/redis/6379.conf
systemd[1]: redis_6379.service lacks ExecStart setting. Refusing.
I think the problem is that we have some overquoting in redis.service.j2
. I end up with this line in the output file /etc/systemd/system/redis_NNNN.service
:
ExecStart="/opt/redis/bin/redis-server" /etc/redis/6379.conf
After manually modifying the file to look like this, I can start the service:
ExecStart=/opt/redis/bin/redis-server /etc/redis/6379.conf
Hey thank you for your role.
Can you make a new release after c7d2afc for ansible v2 ?
I have a use case that will need me to configure Redis to use virtual memory. Looking at the readme/docs I can't find support in your Ansible role for virtual memory options. Are those options unsupported, or just undocumented?
Great module; very nicely setup Redis on my CentOS7 system. Much easier than writing it myself. However, I found myself wanting a couple features:
My first pass looks like this for main.yml
---
- name: Check redis-server version
command: "redis-server --version"
register: redis_sever_version
# May not be installed, or may be the wrong version
# Version format is: Redis server v<version> sha=...
# So [2][1:] is all of the second word except the leading 'v'
changed_when: redis_sever_version.rc or redis_sever_version.stdout.split(' ')[2][1:]|version_compare(redis_version, '<')
failed_when: False
always_run: yes
- include: install.yml
when: redis_sever_version.changed
- file: name=/usr/local/src/redis-{{ redis_version }} state=absent
when: redis_sever_version.changed
- file: name=/usr/local/src/redis-{{ redis_version }}.tar.gz state=absent
when: redis_sever_version.changed
- include: server.yml
when: not redis_sentinel
tags:
- config
- include: sentinel.yml
when: redis_sentinel
tags:
- config
- include: local_facts.yml
since /var/run is not permanent (well, subfolders and files) i added to init script
DAEMON=/opt/redis/bin/redis-server
PIDFOLDER=/var/run/redis
PIDFILE=${PIDFOLDER}/${REDIS_PORT}.pid
REDIS_USER=redis
CONF="/etc/redis/${REDIS_PORT}.conf"
CLIEXEC=/opt/redis/bin/redis-cli
mkdir ${PIDFOLDER}
chown
if [ -r /etc/default/redis_${REDIS_PORT} ]; then
. /etc/default/redis_${REDIS_PORT}
fi
Hello,
I'm using your role in a tool and in the near future I'm going to have it manage role dependencies since it dumps out code using those roles and I want to make sure the correct version of the roles are being used.
My issue is you're not tagging your releases (neither through github releases or standard tags) so there's no way for me to version lock your role.
Can you start tagging them? Thanks.
Hi,
I've specified log file as redis_logfile: /var/log/redis.log
and it caused all the remaining log files in /var/log
have changed owner to redis, e.g:
-rw-r----- 1 redis adm 0 lis 27 06:38 syslog
which essentially caused other nonβroot services either to crash or unable to log .
Need to test against the new stable release.
If this role is defined multiple times with parameterized variables (as in test/test_all.yml), the handler notification can cause some unexpected behaviors due to namespace overlap. Because the handlers are all named the same (e.g. restart redis
or restart sentinel
), multiple role inclusions define the handler the same. When those handlers are later notified, only the handler from the first inclusion is run.
The behavior is much better documented in this issue:
To fix, change the handler name to restart redis {{ redis_port }}
and restart sentinel {{ redis_sentinel_port }}
. We may need to bump the minimum Ansible version in response to this issue.
Hi @DavidWittman ,
When installing sentinel after already have redis installed, it fails in the "add user" step as redis is currently running and the user is attached to it.
TASK: [ansible-redis | add redis user] ****************************************
failed: [ruben-redis-sentinel] => {"failed": true, "name": "redis", "rc": 8}
msg: usermod: user redis is currently used by process 23205
FATAL: all hosts have already failed -- aborting
I guess a quick solution would be to check if the user already exists.
name: check if redis user exists
shell: id {{ redis_user }} 2> /dev/null | wc -l
register: redis_user_exists
- name: add redis user
user:
name={{ redis_user }}
comment="Redis"
home={{ redis_install_dir }}
shell=/bin/false
system=yes
when: redis_user_exists.stdout == "0"
Cheers and thanks for the role.
We may be able to rely on ansible_service_mgr
for detecting which init system to use.
Hi there,
If I want Redis to log to a file rather than stdout
it feels like the playbook should handle the log file existing and being writing by the {{ redis_user }}
. How about something like this in tasks/server.yml
(and equivalent in tasks/sentinel.yml
):
- name: ensure that log file exists and is writable by redis
file: path={{ redis_logfile }}
owner={{ redis_user }}
group={{ redis_user }}
mode=0600
state=touch
when: redis_logfile|length > 0
What d'you reckon? π
If one use a password contains special characters (like $ or ! ), then it expands to shell.
To prevent this use single quote in REDIS_PASSWORD
Ubuntu 16.04 service not working by default.
Problem:
ExecStartPre=-/bin/mkdir /var/run/redis
Fails on service start (after reboot) because /run is tmpfs, and var/run/redis is removed on reboot. The error is:
# systemctl restart redis_2323
Job for redis_2323.service failed because the control process exited with error code. See "systemctl status redis_2323.service" and "journalctl -xe" for details.
# journalctl -xe
mkdir[1937]: /bin/mkdir: cannot create directory '/var/run/redis': Read-only file system
chown[1940]: /bin/chown: cannot access '/var/run/redis': No such file or directory
systemd[1]: redis_2323.service: Control process exited, code=exited status=1
systemd[1]: Failed to start Advanced key-value store.
-- Subject: Unit redis_2323.service has failed
...
For workaround, I set this in the variables:
redis_pidfile: "/var/lib/redis/{{ redis_port }}.pid"
I tried this in the [Service]:
PermissionsStartOnly=true
It did not helped.
Do you have a way to set the default collation and character set like this role:
- name: foobar
collation: "utf8_general_ci" # optional, defaults to "utf8_general_ci"
encoding: "utf8" # optional, defaults to "utf8"
If I run the ansible role and deploy sentinels and a normal redis host, and then later I do it again, it looks like the role rewrites the config file, erasing all of the persistence sentinels have stored there about who the slaves are, and the other sentinels, along with who the current master is.
Is there a way around that, or am I doing something wrong?
Is there a way to edit settings without resetting sentinels back to their initial state?
Hi there,
I've been doing some manual testing with Redis sentinel and its election of a new master. This all works fine as expected π
The issue I've got is that my inventory is currently as follows:
[redis_master]
redis01.staging
[redis_slaves]
redis02.staging
redis03.staging
If, for example, redis02.staging
has previously become the master due to a reelection then re-running the playbook appears to break my setup. If redis01.staging
is still the master then it works fine.
Do you think I need to use a dynamic inventory to calculate which member if redis0[1:3].staging
is the master? I think this issue may be down to the redis-server
config file being rewritten as part of the sentinel re-election process.
Thanks!
Hi,
I've started using your role (thank your for sharing your work), and I've noticed that it is compiling Redis from sources. It's great if you want to have the latest (or a specific) version of it, but not so great when you want the packaged version from the distribution.
I've noticed that the Elasticsearch role is offering the possibility to use the package from the official repository, use a downloaded package or compile from source. It's definitely more complex to handle, but very good for the user, who is able to choose how he wants things to be installed.
Thanks again for sharing this π
OS: Ubuntu 16.04
Ansible: 2.2.0.0
When I run ansible-playbook -i production build.yml
, this exception was happened
TASK [DavidWittman.redis : set redis to start at boot] *************************
fatal: [app]: FAILED! => {"changed": false, "failed": true, "msg": "Could not find the requested service \"'redis_6379'\": "}
then I run
$ sudo systemctl enable redis_6379
redis_6379.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable redis_6379
And Rerun ansible-playbook -i production build.yml
, that exception was not happened.
Maybe it is an ansible bug ?
From the README:
$ ansible-galaxy install DavidWittman.redis
---
- hosts: redis01.example.com
vars:
- redis_bind: 127.0.0.1
roles:
- redis
When I run that:
/data/src/my-app [master]* $ ansible-playbook --i deployment/hosts.test deployment/setup.yml
ERROR: cannot find role in /data/src/my-app/deployment/roles/redis or /data/src/my-app/deployment/redis or /etc/ansible/roles/redis
However, it works when I rename the role to DavidWittman.redis
Hey David, could you add an appropriate license to the repo so that it can be used without legal ambiguity? Cheers!
Hello,
I use a configuration like that.
[redis-master]
redis-1
[redis-slave]
redis-2
redis-3
[redis-sentinel]
redis-1 redis_sentinel=True
redis-2 redis_sentinel=True
redis-3 redis_sentinel=True
in this case, sentinel configuration override the master/slave configuration.
i need to play 2 times my ansible scripts (the second time i have to comment the redis-sentinel section) to have a correct setup.
If the option 32bit
is given to make, redis builds a 32bit binary on a 64bit platform.
It would be useful if this could be a variable.
See http://redis.io/topics/memory-optimization for some of the reasons why this might be desirable.
Since Redis does not provide HTTPS download URLs, it's probably intelligent to verify checksums for the downloaded tarballs. Salvatore provides these checksums in the redis-hashes repository.
This will require a flag to disable verification as well.
Hello there,
this is wonderful but I have noticed if I put as version the testing one which is 3.2 that is not in the standard release url it will not fetch it, so this version will be fine:
http://download.redis.io/releases/redis-3.0.7.tar.gz
But if I type 3.2.0-rc3 which is in the archive the path will be:
https://github.com/antirez/redis/archive/3.2.0-rc3.tar.gz
Could you do a patch to allow also to fetch newer versions from the archive which is here?
Let me know!
The home dir for add redis user
is {{ redis_install_dir }}, which by default is /opt/redis. However, this fails for me if the /opt dir doesn't already exist.
This was on an Ubutu 14.04 VPS.
Hi, DavidWittman,
i have noticed a standard playbook pattern should be:
-- group_vars -- all
-- roles -- redis -- files
-- roles -- redis -- tasks -- main.yml
-- roles -- redis -- templates
-- hosts
-- site.yml
$ ansible-playbook -i hosts site.yml
so i'm just wondering how you organize your playbook structure ? Coz i have not seen this pattern in Ansible Docs.
Thx
This line https://github.com/DavidWittman/ansible-redis/blob/master/tasks/server.yml#L24
fatal: [104.199.185.189]: FAILED! => {"changed": false, "failed": true, "msg": "Could not find the requested service \"'redis_6379'\": "}
I have to manually SSH into the server and run below command
systemctl enable redis_6379
I use Debian Jessie on GCP
The playbook then stop again when i'm trying to deploy sentinel.
I already set ansible_become=true
in the host file
i use ansible 2.2 on OSX.
Please advise
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.