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

Allow change redis version with redis::source recipe #15

Open
wants to merge 2 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
27 changes: 21 additions & 6 deletions recipes/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
install_prefix = node['redis']['source']['prefix']
tar_url = node['redis']['source']['tar_url']
tar_checksum = node['redis']['source']['tar_checksum']
tar_file = "redis-#{node['redis']['source']['version']}.tar.gz"
redis_version = node['redis']['source']['version']
tar_file = "redis-#{redis_version}.tar.gz"
tar_dir = tar_file.sub(/\.tar\.gz$/, '')
port = node['redis']['port']
redis_user = node['redis']['source']['user']
Expand All @@ -50,9 +51,17 @@

execute "Build #{tar_dir.split('/').last}" do
cwd "#{cache_dir}/#{tar_dir}"
command %{make prefix=#{install_prefix} install}
command %{
make prefix=#{install_prefix} install
mv "#{install_prefix}/bin/redis-server" "#{install_prefix}/bin/redis-server-#{redis_version}"
}

creates "#{install_prefix}/bin/redis-server"
creates "#{install_prefix}/bin/redis-server-#{redis_version}"
end

execute "rm -f #{install_prefix}/bin/redis-server"
link "#{install_prefix}/bin/redis-server" do
to "#{install_prefix}/bin/redis-server-#{redis_version}"
end

group redis_group
Expand All @@ -77,18 +86,23 @@

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

creates "/etc/init.d/redis"
creates "/etc/init.d/redis-#{redis_version}"
end

file "/etc/init.d/redis" do
file "/etc/init.d/redis-#{redis_version}" do
owner "root"
group "root"
mode "0755"
end

execute "rm -f /etc/init.d/redis"
link "/etc/init.d/redis" do
to "/etc/init.d/redis-#{redis_version}"
end

service "redis" do
supports :status => false, :restart => false, :reload => false
action :enable
Expand All @@ -105,6 +119,7 @@
owner "root"
group "root"
mode "0644"
variables({:version => node['redis']['source']['version']})

notifies :restart, "service[redis]"
end
Expand Down
7 changes: 5 additions & 2 deletions templates/default/redis.conf.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Redis configuration file example
<% if @version %>
# Configuration of redis version <%= @version %>
<% end %>

# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
Expand Down Expand Up @@ -149,7 +152,7 @@ requirepass <%= node['redis']['password'] %>
appendonly no

# The fsync() call tells the Operating System to actually write data on disk
# instead to wait for more data in the output buffer. Some OS will really flush
# instead to wait for more data in the output buffer. Some OS will really flush
# data on disk, some other OS will just try to do it ASAP.
#
# Redis supports three different modes:
Expand All @@ -173,7 +176,7 @@ appendfsync always
# Glue small output buffers together in order to send small replies in a
# single TCP packet. Uses a bit more CPU but most of the times it is a win
# in terms of number of queries per second. Use 'yes' if unsure.
glueoutputbuf yes
# glueoutputbuf yes

# Use object sharing. Can save a lot of memory if you have many common
# string in your dataset, but performs lookups against the shared objects
Expand Down