Skip to content

Commit

Permalink
Get Redis version from attributes (#299)
Browse files Browse the repository at this point in the history
* Get Redis version from attributes

Also updated README with instructions on how to switch versions

* More Redis recipe cleanup

* README cleanup

* Automatically choose the Redis config file to use based on the version

* Set Redis default to 3.2.3

It was set to 2.8.21 while testing
  • Loading branch information
radamanthus committed Sep 24, 2016
1 parent f175731 commit a585402
Show file tree
Hide file tree
Showing 5 changed files with 1,219 additions and 52 deletions.
19 changes: 8 additions & 11 deletions cookbooks/redis/README.md
Expand Up @@ -36,30 +36,27 @@ default[:redis] = {
Changing Defaults
--------

A large portion of the defaults of this recipe have been moved to a attribute file; if you need to change how often you save; review the attribute file and modify.
A large portion of the defaults of this recipe have been moved to the `attributes/default.rb` file. If you need to change how often you save, review the attribute file and modify.

Installation
--------

Ensure you have the Dependencies installed in your local cookbooks repository ...
Add the following to your main/recipes/default.rb

``include_recipe "redis"``

Upgrading from a previous Redis version
---

Before upgrading, please review the Redis release notes for the version you're upgrading to, to ensure compatibility with your current Redis data. After upgrading, Redis server will be installed to `/usr/local/bin/redis-server`. However, the old version of Redis will still be running. Please run `sudo monit restart redis-1` to restart Redis.

Choosing a different Redis version
--------
This recipe installs Redis 2.8.13-r1 by default. We do not recommend earlier versions of Redis 2.8.x or 2.6.x as these versions have a known vulnerability: http://benmmurphy.github.io/blog/2015/06/04/redis-eval-lua-sandbox-escape/
This recipe installs Redis 3.2.3 by default. For Redis 2.x we do not recommend versions earlier than Redis 2.8.21, and for Redis 3.x we do not recommend versions earlier than 3.0.2. These versions have a known vulnerability: http://benmmurphy.github.io/blog/2015/06/04/redis-eval-lua-sandbox-escape/

To install a different version of Redis:
To install a different version of Redis, change the `:version => "3.2.3",` line in `attributes/default.rb` to the version you want to install. If you're upgrading to a newer version, please see the "Upgrading" section below.

Upgrading from a previous Redis version
--------

1. Change the `:version => "2.8.13-r1",` line in `attributes/default.rb` to the version you want to install
2. Copy over the corresponding `redis-?.?.conf.erb` file to `templates/default/redis.conf.erb`
Before upgrading, please review the Redis release notes for the version you're upgrading to, to ensure compatibility with your current Redis data. Also ensure that you remove the `/data/redis-source` directory - the recipe skips downloading and installing a new version if this directory is present.

After upgrading, Redis server will be installed to `/usr/local/bin/redis-server`. However, the old version of Redis will still be running. Please run `sudo monit restart redis-1` to restart Redis.

Notes
------
Expand Down
2 changes: 1 addition & 1 deletion cookbooks/redis/attributes/default.rb
@@ -1,6 +1,6 @@
default[:redis] = {
:utility_name => "redis",
:version => "2.8.13-r1",
:version => "3.2.3",
:bindport => "6379",
:unixsocket => "/tmp/redis.sock",
:basename => "dump.rdb",
Expand Down
5 changes: 3 additions & 2 deletions cookbooks/redis/recipes/default.rb
Expand Up @@ -3,7 +3,8 @@
# Recipe:: default
#

redis_version = '3.2.3'
redis_version = node[:redis][:version]
redis_config_file_version = redis_version.split('.')[0..1].join('.')
redis_url = "http://download.redis.io/releases/redis-#{redis_version}.tar.gz"
redis_source_directory = 'redis-source'
bin_path = '/usr/local/bin'
Expand Down Expand Up @@ -51,7 +52,7 @@
owner 'root'
group 'root'
mode 0644
source "redis.conf.erb"
source "redis-#{redis_config_file_version}.conf.erb"
variables({
:pidfile => node[:redis][:pidfile],
:basedir => node[:redis][:basedir],
Expand Down

0 comments on commit a585402

Please sign in to comment.