Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added config attributes. #13

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 77 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DESCRIPTION:

Installs Redis. Redis is an open source, advanced key-value store.
Installs Redis. Redis is an open source, advanced key-value store.

It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

Expand All @@ -14,21 +14,82 @@ Currently tested on Ubuntu 10.04 ONLY.

# ATTRIBUTES:

['redis']['bind'] # "127.0.0.1"
['redis']['port'] # "6379"
['redis']['config_path'] # "/etc/redis/redis.conf"
['redis']['daemonize'] # "no"
['redis']['timeout'] # "300"
['redis']['loglevel'] # "notice"
['redis']['password'] # nil

['redis']['source']['version'] # "2.4.1"
['redis']['source']['prefix'] # "/usr/local"
['redis']['source']['tar_url'] # "http://redis.googlecode.com/files/redis-2.4.1.tar.gz"
['redis']['source']['tar_checksum'] # "38e02..."
['redis']['source']['create_service'] # true
['redis']['source']['user'] # "redis"
['redis']['source']['group'] # "redis"
['redis']['config_path'] # "/etc/redis/redis.conf"
['redis']['daemonize'] # "no"
['redis']['pidfile'] # "/var/run/redis.pid"
['redis']['port'] # "6379"
['redis']['bind'] # "127.0.0.1"
['redis']['unixsocket'] # nil
['redis']['unixsocketperm'] # nil
['redis']['timeout'] # "300"
['redis']['loglevel'] # "notice"
['redis']['logfile'] # "/var/log/redis/redis-server.log"
['redis']['syslog-enabled'] # "no"
['redis']['syslog-ident'] # "redis"
['redis']['syslog-facility'] # "local0"
['redis']['databases'] # 16
['redis']['save'] # { 900 => 1, 300 => 10, 60 => 1000
['redis']['rdbcompression'] # "yes"}
['redis']['dbfilename'] # "dump.rdb"
['redis']['dir'] # "/var/lib/redis"

### Replication

['redis']['slaveof']['ip'] # nil
['redis']['slaveof']['port'] # nil
['redis']['masterauth'] # nil
['redis']['slave-serve-stale-data'] # "yes"
['redis']['repl-ping-slave-period'] # 10

### Security

['redis']['password'] # nil
['redis']['rename-command'] # { }

### Limits

['redis']['maxclients'] # nil
['redis']['maxmemory'] # nil
['redis']['maxmemory-policy'] # nil

### Append Only Mode

['redis']['appendonly'] # "no"
['redis']['appendfsync'] # "everysec" (everysec, always, no)
['redis']['no-appendfsync-on-rewrite'] # "no"
['redis']['auto-aof-rewrite-percentage'] # 100
['redis']['auto-aof-rewrite-min-size'] # "64mb"

### Slow Log

['redis']['slowlog-log-slower-than'] # 10000
['redis']['slowlog-max-len'] # 128

### Advanced Options

['redis']['hash-max-zipmap-entries'] # 512
['redis']['hash-max-zipmap-value'] # 64
['redis']['list-max-ziplist-entries'] # 512
['redis']['list-max-ziplist-value'] # 64
['redis']['set-max-intset-entries'] # 512
['redis']['zset-max-ziplist-entries'] # 128
['redis']['zset-max-ziplist-value'] # 64
['redis']['activerehashing'] # "yes"
['redis']['include'] # [ ]

### Compile From Source Options

['redis']['source']['version'] # "2.4.1"
['redis']['source']['prefix'] # "/usr/local"
['redis']['source']['tar_url'] # "http://redis.googlecode.com/files/redis-2.4.1.tar.gz"
['redis']['source']['tar_checksum'] # "38e02..."
['redis']['source']['create_service'] # true
['redis']['source']['user'] # "redis"
['redis']['source']['group'] # "redis"

### Gem Options

['redis']['gem']['packages'] # "redis"

# USAGE:

Expand Down
64 changes: 57 additions & 7 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,60 @@
# See the License for the specific language governing permissions and
# limitations under the License.

default['redis']['bind'] = "127.0.0.1"
default['redis']['port'] = "6379"
default['redis']['config_path'] = "/etc/redis/redis.conf"
default['redis']['daemonize'] = "no"
default['redis']['timeout'] = "300"
default['redis']['loglevel'] = "notice"
default['redis']['password'] = nil
# Global Options
default['redis']['config_path'] = "/etc/redis/redis.conf"
default['redis']['daemonize'] = "no"
default['redis']['pidfile'] = "/var/run/redis.pid"
default['redis']['port'] = "6379"
default['redis']['bind'] = "127.0.0.1"
default['redis']['unixsocket'] = nil
default['redis']['unixsocketperm'] = nil
default['redis']['timeout'] = "300"
default['redis']['loglevel'] = "notice"
default['redis']['logfile'] = "/var/log/redis/redis-server.log"
default['redis']['syslog-enabled'] = "no"
default['redis']['syslog-ident'] = "redis"
default['redis']['syslog-facility'] = "LOCAL0"
default['redis']['databases'] = 16
default['redis']['save'] = {} #{ 900 => 1, 300 => 10, 60 => 1000 }
default['redis']['rdbcompression'] = "yes"
default['redis']['dbfilename'] = "dump.rdb"
default['redis']['dir'] = "/var/lib/redis"

# Replication
default['redis']['slaveof']['ip'] = nil
default['redis']['slaveof']['port'] = nil
default['redis']['masterauth'] = nil
default['redis']['slave-serve-stale-data'] = "yes"
default['redis']['repl-ping-slave-period'] = 10

# Security
default['redis']['password'] = nil
default['redis']['rename-command'] = { }

# Limits
default['redis']['maxclients'] = nil
default['redis']['maxmemory'] = nil
default['redis']['maxmemory-policy'] = nil

# Append Only Mode
default['redis']['appendonly'] = "no"
default['redis']['appendfsync'] = "everysec" # everysec, always, no
default['redis']['no-appendfsync-on-rewrite'] = "no"
default['redis']['auto-aof-rewrite-percentage'] = 100
default['redis']['auto-aof-rewrite-min-size'] = "64mb"

# Slow Log
default['redis']['slowlog-log-slower-than'] = 10000
default['redis']['slowlog-max-len'] = 128

# Advanced Options
default['redis']['hash-max-zipmap-entries'] = 512
default['redis']['hash-max-zipmap-value'] = 64
default['redis']['list-max-ziplist-entries'] = 512
default['redis']['list-max-ziplist-value'] = 64
default['redis']['set-max-intset-entries'] = 512
default['redis']['zset-max-ziplist-entries'] = 128
default['redis']['zset-max-ziplist-value'] = 64
default['redis']['activerehashing'] = "yes"
default['redis']['include'] = [ ]
12 changes: 6 additions & 6 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
license "All rights reserved"
description "Installs/Configures redis"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.0.4"
recipe "redis", "Includes the package recipe by default."
recipe "redis::package", "Sets up a redis server."
recipe "redis::gem", "Installs redis gem for ruby development."
recipe "redis::source", "Builds redis server from sources."
recipe "redis::remove", "Removes redis server and redis gem, if installed."
version "0.0.6"
recipe "redis", "Includes the package recipe by default."
recipe "redis::package", "Sets up a redis server."
recipe "redis::gem", "Installs redis gem for ruby development."
recipe "redis::source", "Builds redis server from sources."
recipe "redis::remove", "Removes redis server and redis gem, if installed."

%w{ ubuntu debian }.each do |os|
supports os
Expand Down
2 changes: 1 addition & 1 deletion recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
# limitations under the License.
#

include_recipe "redis::package"
include_recipe "redis::package"
1 change: 0 additions & 1 deletion recipes/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@
node['redis']['gem']['packages'].each do |pkg|
gem_package pkg
end

3 changes: 2 additions & 1 deletion recipes/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
action :start
end

template "/etc/redis/redis.conf" do
template "#{node[:redis][:config_path]}" do
source "redis.conf.erb"
owner "root"
group "root"
mode 0644

notifies :restart, resources(:service => "redis")
end
25 changes: 10 additions & 15 deletions recipes/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@

user redis_user do
gid redis_group
home "/var/lib/redis"
home node[:redis][:dir]
system true
end

%w{/var/run/redis.pid /var/log/redis /var/lib/redis}.each do |dir|
[File.dirname(node[:redis][:config_path]), File.dirname(node[:redis][:logfile]), node[:redis][:dir]].each do |dir|
directory dir do
owner redis_user
group redis_group
Expand All @@ -75,32 +75,27 @@
if node['redis']['source']['create_service']
node.set['redis']['daemonize'] = "yes"

execute "Install redis-server init.d script" do
command <<-COMMAND
cp #{cache_dir}/#{tar_dir}/utils/redis_init_script /etc/init.d/redis
COMMAND

creates "/etc/init.d/redis"
service "redis" do
supports :status => false, :restart => false, :reload => false
end

file "/etc/init.d/redis" do
template "/etc/init.d/redis" do
source "init.sh.erb"
owner "root"
group "root"
mode "0755"
end

service "redis" do
supports :status => false, :restart => false, :reload => false
action :enable
notifies :restart, "service[redis]"
end

directory "/etc/redis" do
directory File.dirname("#{node[:redis][:config_path]}") do
owner "root"
group "root"
mode "0755"
recursive true
end

template "/etc/redis/#{port}.conf" do
template "#{node[:redis][:config_path]}" do
source "redis.conf.erb"
owner "root"
group "root"
Expand Down
44 changes: 44 additions & 0 deletions templates/default/init.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
#
# This file is managed by chef, any changes are likely to be lost.

EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli

PIDFILE="<%= node[:redis][:pidfile] %>"
REDISPORT="<%= node[:redis][:port] %>"
CONF="<%= node[:redis][:config_path] %>"

case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use start or stop as first argument"
;;
esac
Loading