From 224db66b7161760de1827c6547c4a1e9beaa5991 Mon Sep 17 00:00:00 2001 From: Seth Thomas Date: Mon, 25 Feb 2013 10:06:11 -0600 Subject: [PATCH] Updates for 1.3 --- README.md | 5 +- attributes/default.rb | 66 ++++++++++++------ attributes/package.rb | 13 ++-- attributes/source.rb | 27 ++++++++ metadata.rb | 13 +++- recipes/default.rb | 151 ++++++++++++++++++++---------------------- recipes/source.rb | 81 ++++++++++++++++++++++ 7 files changed, 247 insertions(+), 109 deletions(-) create mode 100644 attributes/source.rb create mode 100644 recipes/source.rb diff --git a/README.md b/README.md index 08f5306..091ca3f 100644 --- a/README.md +++ b/README.md @@ -21,16 +21,15 @@ There are two options for package installation: binary and source. If you are u The package parameters available are version, type and, optionally for source installation, an install prefix: node['riak']['package']['version']['major'] = "1" - node['riak']['package']['version']['minor'] = "2" + node['riak']['package']['version']['minor'] = "3" node['riak']['package']['version']['incremental'] = "0" - node['riak']['package']['type'] = ("binary" | "source") node['riak']['package']['prefix'] = "/usr/local" Basic Configuration ------------------- -Most Riak configuration is for networking, Erlang, and storage backends. The only, interesting configuration options outside of those is the filesystem path where ring state files should be stored. +Most Riak configuration is for networking, Erlang, and storage backends. The only interesting configuration options outside of those is the filesystem path where ring state files should be stored. node['riak']['config']['riak_core']['ring_state_dir'] = "/var/lib/riak/ring".to_erl_string diff --git a/attributes/default.rb b/attributes/default.rb index 6d63605..2de14f9 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -2,7 +2,7 @@ # Author:: Seth Thomas () # Cookbook Name:: riak # -# Copyright (c) 2012 Basho Technologies, Inc. +# Copyright (c) 2013 Basho Technologies, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,15 +17,26 @@ # limitations under the License. # +platform_bin_dir = "/usr/sbin" +platform_data_dir = "/var/lib/riak" +platform_etc_dir = "/etc/riak" +platform_lib_dir = "/usr/lib/riak" +platform_log_dir = "/var/log/riak" + # vm.args -default['riak']['args']['-name'] = "riak@#{node['ipaddress']}" +default['riak']['args']['-name'] = "riak@#{node['fqdn']}" default['riak']['args']['-setcookie'] = "riak" default['riak']['args']['+K'] = true default['riak']['args']['+A'] = 64 default['riak']['args']['+W'] = "w" default['riak']['args']['-env']['ERL_MAX_PORTS'] = 4096 default['riak']['args']['-env']['ERL_FULLSWEEP_AFTER'] = 0 -default['riak']['args']['-env']['ERL_CRASH_DUMP'] = "/var/log/riak/erl_crash.dump" +default['riak']['args']['-env']['ERL_CRASH_DUMP'] = "#{platform_log_dir}/erl_crash.dump" +default['riak']['args']['-env']['ERL_MAX_ETS_TABLES'] = 8192 +default['riak']['args']['-smp'] = "enable" +#default['riak']['args']['-proto_dist'] = "inet_ssl" +#default['riak']['args']['-ssl_dist_opt']['client_certfile'] = "\"#{platform_etc_dir}/erlclient.pem\"" +#default['riak']['args']['-ssl_dist_opt']['server_certfile'] = "\"#{platform_etc_dir}/erlserver.pem\"" # app.config class ::String @@ -36,27 +47,39 @@ class ::Array include Eth::Erlang::Array end -#kernel +# kernel default['riak']['config']['kernel']['inet_dist_listen_min'] = 6000 default['riak']['config']['kernel']['inet_dist_listen_max'] = 7999 -#riak_api +# riak_api +default['riak']['config']['riak_api']['pb_backlog'] = 64 default['riak']['config']['riak_api']['pb_ip'] = "#{node['ipaddress']}".to_erl_string default['riak']['config']['riak_api']['pb_port'] = 8087 # riak_core -default['riak']['config']['riak_core']['ring_state_dir'] = "/var/lib/riak/ring".to_erl_string +default['riak']['config']['riak_core']['ring_state_dir'] = "#{platform_data_dir}/ring".to_erl_string default['riak']['config']['riak_core']['ring_creation_size'] = 64 default['riak']['config']['riak_core']['http'] = [["#{node['ipaddress']}".to_erl_string, 8098].to_erl_tuple] +#default['riak']['config']['riak_core']['https'] = [["#{node['ipaddress']}".to_erl_string, 8098].to_erl_tuple] +#default['riak']['config']['riak_core']['ssl'] = [["certfile", "./etc/cert.pem".to_erl_string].to_erl_tuple, ["keyfile", "./etc/key.pem".to_erl_string].to_erl_tuple] default['riak']['config']['riak_core']['handoff_port'] = 8099 +#default['riak']['config']['riak_core']['handoff_ssl_options'] = [["certfile", "tmp/erlserver.pem".to_erl_string].to_erl_tuple] default['riak']['config']['riak_core']['dtrace_support'] = false -default['riak']['config']['riak_core']['platform_bin_dir'] = "/usr/sbin".to_erl_string -default['riak']['config']['riak_core']['platform_data_dir'] = "/var/lib/riak".to_erl_string -default['riak']['config']['riak_core']['platform_etc_dir'] = "/etc/riak".to_erl_string -default['riak']['config']['riak_core']['platform_lib_dir'] = "/usr/lib/riak".to_erl_string -default['riak']['config']['riak_core']['platform_log_dir'] = "/var/log/riak".to_erl_string +default['riak']['config']['riak_core']['enable_health_checks'] = true +default['riak']['config']['riak_core']['platform_bin_dir'] = platform_bin_dir.to_erl_string +default['riak']['config']['riak_core']['platform_data_dir'] = platform_data_dir.to_erl_string +default['riak']['config']['riak_core']['platform_etc_dir'] = platform_etc_dir.to_erl_string +default['riak']['config']['riak_core']['platform_lib_dir'] = platform_lib_dir.to_erl_string +default['riak']['config']['riak_core']['platform_log_dir'] = platform_log_dir.to_erl_string # riak_kv +default['riak']['config']['riak_kv']['anti_entropy'] = ["on", []].to_erl_tuple +default['riak']['config']['riak_kv']['anti_entropy_build_limit'] = [1, 3600000].to_erl_tuple +default['riak']['config']['riak_kv']['anti_entropy_expire'] = 604800000 +default['riak']['config']['riak_kv']['anti_entropy_concurrency'] = 2 +default['riak']['config']['riak_kv']['anti_entropy_tick'] = 1500 +default['riak']['config']['riak_kv']['anti_entropy_data_dir'] = "#{platform_data_dir}/anti_entropy".to_erl_string +default['riak']['config']['riak_kv']['anti_entropy_leveldb_opts'] = [["write_buffer_size", 4194304].to_erl_tuple, ["max_open_files", 20].to_erl_tuple] default['riak']['config']['riak_kv']['mapred_name'] = "mapred".to_erl_string default['riak']['config']['riak_kv']['mapred_system'] = "pipe" default['riak']['config']['riak_kv']['mapred_2i_pipe'] = true @@ -65,33 +88,35 @@ class ::Array default['riak']['config']['riak_kv']['hook_js_vm_count'] = 2 default['riak']['config']['riak_kv']['js_max_vm_mem'] = 8 default['riak']['config']['riak_kv']['js_thread_stack'] = 16 +#default['riak']['config']['riak_kv']['js_source_dir'] = "/tmp/js_source".to_erl_string default['riak']['config']['riak_kv']['http_url_encoding'] = "on" default['riak']['config']['riak_kv']['vnode_vclocks'] = true -default['riak']['config']['riak_kv']['legacy_keylisting'] = false default['riak']['config']['riak_kv']['listkeys_backpressure'] = true +default['riak']['config']['riak_kv']['vnode_mailbox_limit'] = [1, 5000].to_erl_tuple # riak_kv storage_backend default['riak']['config']['riak_kv']['storage_backend'] = "riak_kv_bitcask_backend" case node['riak']['config']['riak_kv']['storage_backend'] when "riak_kv_bitcask_backend" - default['riak']['config']['bitcask']['data_root'] = "/var/lib/riak/bitcask".to_erl_string + default['riak']['config']['bitcask']['io_mode'] = "erlang" + default['riak']['config']['bitcask']['data_root'] = "#{platform_data_dir}/bitcask".to_erl_string when "riak_kv_eleveldb_backend" - default['riak']['config']['eleveldb']['data_root'] = "/var/lib/riak/leveldb".to_erl_string + default['riak']['config']['eleveldb']['data_root'] = "#{platform_data_dir}/leveldb".to_erl_string end # riak_search default['riak']['config']['riak_search']['enabled'] = false # merge_index -default['riak']['config']['merge_index']['data_root'] = "/var/lib/riak/merge_index".to_erl_string +default['riak']['config']['merge_index']['data_root'] = "#{platform_data_dir}/merge_index".to_erl_string default['riak']['config']['merge_index']['buffer_rollover_size'] = 1048576 default['riak']['config']['merge_index']['max_compact_segments'] = 20 # lager -error_log = ["/var/log/riak/error.log".to_erl_string,"error",10485760,"$D0".to_erl_string,5].to_erl_tuple -info_log = ["/var/log/riak/console.log".to_erl_string,"info",10485760,"$D0".to_erl_string,5].to_erl_tuple +error_log = ["#{platform_log_dir}/error.log".to_erl_string,"error",10485760,"$D0".to_erl_string,5].to_erl_tuple +info_log = ["#{platform_log_dir}/console.log".to_erl_string,"info",10485760,"$D0".to_erl_string,5].to_erl_tuple default['riak']['config']['lager']['handlers']['lager_file_backend'] = [error_log, info_log] -default['riak']['config']['lager']['crash_log'] = "/var/log/riak/crash.log".to_erl_string +default['riak']['config']['lager']['crash_log'] = "#{platform_log_dir}/crash.log".to_erl_string default['riak']['config']['lager']['crash_log_msg_size'] = 65536 default['riak']['config']['lager']['crash_log_size'] = 10485760 default['riak']['config']['lager']['crash_log_date'] = "$D0".to_erl_string @@ -101,7 +126,7 @@ class ::Array # riak_sysmon default['riak']['config']['riak_sysmon']['process_limit'] = 30 default['riak']['config']['riak_sysmon']['port_limit'] = 2 -default['riak']['config']['riak_sysmon']['gc_ms_limit'] = 100 +default['riak']['config']['riak_sysmon']['gc_ms_limit'] = 0 default['riak']['config']['riak_sysmon']['heap_word_limit'] = 40111000 default['riak']['config']['riak_sysmon']['busy_port'] = true default['riak']['config']['riak_sysmon']['busy_dist_port'] = true @@ -115,3 +140,6 @@ class ::Array default['riak']['config']['riak_control']['auth'] = "userlist" default['riak']['config']['riak_control']['userlist'] = [["user".to_erl_string,"pass".to_erl_string].to_erl_tuple] default['riak']['config']['riak_control']['admin'] = true + +#patches +default['riak']['patches'] = [] diff --git a/attributes/package.rb b/attributes/package.rb index 38ec826..b58d898 100644 --- a/attributes/package.rb +++ b/attributes/package.rb @@ -2,7 +2,7 @@ # Author:: Benjamin Black () and Sean Cribbs () # Cookbook Name:: riak # -# Copyright (c) 2012 Basho Technologies, Inc. +# Copyright (c) 2013 Basho Technologies, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,10 +17,13 @@ # limitations under the License. # -default['riak']['package']['type'] = "binary" +default['riak']['package']['url'] = "http://s3.amazonaws.com/downloads.basho.com/riak" default['riak']['package']['version']['major'] = "1" -default['riak']['package']['version']['minor'] = "2" -default['riak']['package']['version']['incremental'] = "1" +default['riak']['package']['version']['minor'] = "3" +default['riak']['package']['version']['incremental'] = "0" default['riak']['package']['version']['build'] = "1" -default['riak']['package']['source_checksum'] = '7646c0deba6730d45e211b487e16e0b4f1d41ffbc47af358e85c7bf59cfa0a98' default['riak']['package']['config_dir'] = "/etc/riak" +default['riak']['package']['local_package'] = false + +default['riak']['package']['checksum']['fedora']['17'] = "3c8dfccab67e74a886c6bfdcaa7a0f81bcb29b2c656a41b99d50b58d329cdde3" +default['riak']['package']['checksum']['local'] = nil diff --git a/attributes/source.rb b/attributes/source.rb new file mode 100644 index 0000000..d6cc87c --- /dev/null +++ b/attributes/source.rb @@ -0,0 +1,27 @@ +# +# Author:: Benjamin Black () and Sean Cribbs () +# Cookbook Name:: riak +# +# Copyright (c) 2013 Basho Technologies, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +default['riak']['source']['url'] = "http://s3.amazonaws.com/downloads.basho.com/riak" +default['riak']['source']['version']['major'] = "1" +default['riak']['source']['version']['minor'] = "3" +default['riak']['source']['version']['incremental'] = "0" +default['riak']['source']['prefix'] = "/usr/local" +default['riak']['source']['config_dir'] = node['riak']['source']['prefix'] + "/riak/etc" + +default['riak']['source']['checksum'] = '424d159a848825614a5e719df7b743dbeee6c1828566a6c9ec2e06c33b0b86fe' + diff --git a/metadata.rb b/metadata.rb index 7eb8222..538a2a1 100644 --- a/metadata.rb +++ b/metadata.rb @@ -2,7 +2,7 @@ # Author:: Benjamin Black () and Sean Cribbs () # Cookbook Name:: riak # -# Copyright (c) 2012 Basho Technologies, Inc. +# Copyright (c) 2013 Basho Technologies, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,8 +21,15 @@ maintainer_email "riak@basho.com" license "Apache 2.0" description "Installs and configures Riak distributed data store" -version "1.2.1" -recipe "riak", "Installs Riak" +version "1.3.0" +depends "apt" +depends "yum" +depends "build-essential" +depends "erlang" + +recipe "riak", "Installs Riak from a package" +recipe "riak::source", "Installs Erlang and Riak from source" + %w{ubuntu debian centos redhat fedora}.each do |os| supports os diff --git a/recipes/default.rb b/recipes/default.rb index cbaae33..2475397 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -1,9 +1,9 @@ # -# Author:: Benjamin Black () and Sean Cribbs () +# Author:: Seth Thomas () # Cookbook Name:: riak # Recipe:: default # -# Copyright (c) 2012 Basho Technologies, Inc. +# Copyright (c) 2013 Basho Technologies, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,96 +19,80 @@ # version_str = "#{node['riak']['package']['version']['major']}.#{node['riak']['package']['version']['minor']}" -base_uri = "http://s3.amazonaws.com/downloads.basho.com/riak/#{version_str}/#{version_str}.#{node['riak']['package']['version']['incremental']}/" +base_uri = "#{node['riak']['package']['url']}/#{version_str}/#{version_str}.#{node['riak']['package']['version']['incremental']}/" base_filename = "riak-#{version_str}.#{node['riak']['package']['version']['incremental']}" -case node['riak']['package']['type'] - when "binary" - case node['platform'] - when "ubuntu" - machines = {"x86_64" => "amd64", "i386" => "i386", "i686" => "i386"} - base_uri = "#{base_uri}#{node['platform']}/#{node['lsb']['codename']}/" - package "libssl0.9.8" - package_file = "#{base_filename.gsub(/\-/, '_')}-#{node['riak']['package']['version']['build']}_#{machines[node['kernel']['machine']]}.deb" - when "debian" - machines = {"x86_64" => "amd64", "i386" => "i386", "i686" => "i386"} - base_uri = "#{base_uri}#{node['platform']}/squeeze/" - package_file = "#{base_filename.gsub(/\-/, '_').sub(/_/,'-')}-#{node['riak']['package']['version']['build']}_#{machines[node['kernel']['machine']]}.deb" - when "redhat","centos" - machines = {"x86_64" => "x86_64", "i386" => "i386", "i686" => "i686"} - base_uri = "#{base_uri}rhel/#{node['platform_version'].to_i}/" - package_file = "#{base_filename}-#{node['riak']['package']['version']['build']}.el#{node['platform_version'].to_i}.#{machines[node['kernel']['machine']]}.rpm" - node['riak']['config']['riak_core']['platform_lib_dir'] = "/usr/lib64/riak".to_erl_string if node['kernel']['machine'] == 'x86_64' - when "fedora" - machines = {"x86_64" => "x86_64", "i386" => "i386", "i686" => "i686"} - base_uri = "#{base_uri}#{node['platform']}/#{node['platform_version'].to_i}/" - package_file = "#{base_filename}-#{node['riak']['package']['version']['build']}.fc#{node['platform_version'].to_i}.#{node['kernel']['machine']}.rpm" - node['riak']['config']['riak_core']['platform_lib_dir'] = "/usr/lib64/riak".to_erl_string if node['kernel']['machine'] == 'x86_64' - end - when "source" - package_file = "#{base_filename.sub(/\-/, '_')}.tar.gz" - node['riak']['package']['prefix'] = "/usr/local" - node['riak']['package']['config_dir'] = node['riak_eds']['package']['prefix'] + "/riak/etc" +case node['platform'] +when "fedora", "centos", "redhat" + node.set['riak']['config']['riak_core']['platform_lib_dir'] = "/usr/lib64/riak".to_erl_string if node['kernel']['machine'] == 'x86_64' + machines = {"x86_64" => "x86_64", "i386" => "i386", "i686" => "i686"} + base_uri = "#{base_uri}#{node['platform']}/#{node['platform_version'].to_i}/" + package_file = "#{base_filename}-#{node['riak']['package']['version']['build']}.fc#{node['platform_version'].to_i}.#{node['kernel']['machine']}.rpm" + package_uri = base_uri + package_file + package_name = package_file.split("[-_]\d+\.").first +end + +if node['riak']['package']['local_package'] == true + package_file = node['riak']['package']['local_package'] + + cookbook_file "#{Chef::Config[:file_cache_path]}/#{package_file}" do + source package_file + owner "root" + mode 0644 + not_if(File.exists?("#{Chef::Config[:file_cache_path]}/#{package_file}") && Digest::SHA256.file("#{Chef::Config[:file_cache_path]}/#{package_file}").hexdigest == checksum_val) end +else + case node['platform'] + when "ubuntu", "debian" + include_recipe "apt" + + apt_repository "basho" do + uri "http://apt.basho.com" + distribution node['lsb']['codename'] + components ["main"] + key "http://apt.basho.com/gpg/basho.apt.key" + end -package_uri = base_uri + package_file + package "riak" do + action :install + end -package_name = package_file.split("[-_]\d+\.").first + when "centos", "rhel" + include_recipe "yum" -group "riak" + yum_key "RPM-GPG-KEY-basho" do + url "http://yum.basho.com/gpg/RPM-GPG-KEY-basho" + action :add + end -user "riak" do - gid "riak" - shell "/bin/bash" - home "/var/lib/riak" - system true -end + yum_repository "basho" do + repo_name "basho" + description "Basho Stable Repo" + url "http://yum.basho.com/el/#{node['platform_version'].to_i}/products/x86_64/" + key "RPM-GPG-KEY-basho" + action :add + end -remote_file "#{Chef::Config[:file_cache_path]}/#{package_file}" do - source package_uri - owner "root" - mode 0644 - checksum node['riak']['package']['source_checksum'] - not_if { File.exists?("#{Chef::Config[:file_cache_path]}/#{package_file}") } -end + package "riak" do + action :install + end -case node['riak']['package']['type'] -when "binary" - package package_name do - source "#{Chef::Config[:file_cache_path]}/#{package_file}" - action :install - options case node['platform'] - when "debian","ubuntu" - "--force-confdef --force-confold" - end - provider value_for_platform( - [ "ubuntu", "debian" ] => {"default" => Chef::Provider::Package::Dpkg}, - [ "redhat", "centos", "fedora" ] => {"default" => Chef::Provider::Package::Rpm} - ) - end -when "source" - execute "riak-src-unpack" do - cwd Chef::Config[:file_cache_path] - command "tar xvfz #{package_file}" - end + when "fedora" - execute "riak-src-build" do - cwd "#{Chef::Config[:file_cache_path]}/#{base_filename}" - command "make clean all rel" - end + remote_file "#{Chef::Config[:file_cache_path]}/#{package_file}" do + source package_uri + owner "root" + mode 0644 + not_if(File.exists?("#{Chef::Config[:file_cache_path]}/#{package_file}") && Digest::SHA256.file("#{Chef::Config[:file_cache_path]}/#{package_file}").hexdigest == node['riak']['package']['checksum']['local']) + end - execute "riak-src-install" do - command "mv #{Chef::Config[:file_cache_path]}/#{base_filename}/rel/riak #{node['riak']['package']['prefix']}" - not_if { File.directory?("#{node['riak']['package']['prefix']}/riak") } + package package_name do + source "#{Chef::Config[:file_cache_path]}/#{package_file}" + action :install + end end end -directory node['riak']['package']['config_dir'] do - owner "root" - mode "0755" - action :create -end - file "#{node['riak']['package']['config_dir']}/app.config" do content Eth::Config.new(node['riak']['config'].to_hash).pp owner "root" @@ -121,10 +105,19 @@ mode 0644 end +node['riak']['patches'].each do |patch| + cookbook_file "#{node['riak']['config']['riak_core']['platform_lib_dir'].gsub(/__string_/,'')}/lib/basho-patches/#{patch}" do + source patch + owner "root" + mode 0644 + checksum + notifies :restart, "service[riak]" + end +end + service "riak" do supports :start => true, :stop => true, :restart => true action [ :enable ] subscribes :restart, resources(:file => [ "#{node['riak']['package']['config_dir']}/app.config", "#{node['riak']['package']['config_dir']}/vm.args" ]) - only_if { node['riak']['package']['type'] == "binary" } end diff --git a/recipes/source.rb b/recipes/source.rb new file mode 100644 index 0000000..d8553a2 --- /dev/null +++ b/recipes/source.rb @@ -0,0 +1,81 @@ +# +# Author:: Seth Thomas () +# Cookbook Name:: riak +# Recipe:: source +# +# Copyright (c) 2013 Basho Technologies, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +source_version = "#{node['riak']['source']['version']['major']}.#{node['riak']['source']['version']['minor']}" +source_uri = "#{node['riak']['source']['url']}/#{source_version}/#{source_version}.#{node['riak']['source']['version']['incremental']}/" +source_file = "riak-#{source_version}.#{node['riak']['source']['version']['incremental']}" +source_filename = "#{source_file}.tar.gz" + +include_recipe "git" +include_recipe "build-essential" +include_recipe "erlang::source" + +group "riak" + +user "riak" do + gid "riak" + shell "/bin/bash" + home "/var/lib/riak" + system true +end + +remote_file "#{Chef::Config[:file_cache_path]}/#{source_filename}" do + source source_uri + source_filename + owner "root" + mode 0644 + not_if { File.exists?("#{Chef::Config[:file_cache_path]}/#{source_filename}") && Digest::SHA256.file("#{Chef::Config[:file_cache_path]}/#{source_filename}").hexdigest == node['riak']['source']['checksum'] } +end + +execute "riak-src-unpack" do + cwd Chef::Config[:file_cache_path] + command "tar xvfz #{source_filename}" +end + +execute "riak-src-build" do + cwd "#{Chef::Config[:file_cache_path]}/#{source_file}" + command "make clean all rel" +end + +execute "riak-src-install" do + command "mv #{Chef::Config[:file_cache_path]}/#{source_file}/rel/riak #{node['riak']['source']['prefix']}" + not_if { File.directory?("#{node['riak']['source']['prefix']}/riak") } +end + +file "#{node['riak']['source']['config_dir']}/app.config" do + content Eth::Config.new(node['riak']['config'].to_hash).pp + owner "root" + mode 0644 +end + +file "#{node['riak']['source']['config_dir']}/vm.args" do + content Eth::Args.new(node['riak']['args'].to_hash).pp + owner "root" + mode 0644 +end + +node['riak']['patches'].each do |patch| + cookbook_file "#{node['riak']['source']['prefix']}/riak/lib/basho-patches/#{patch}" do + source patch + owner "root" + mode 0644 + checksum + notifies :restart, "service[riak]" + end +end \ No newline at end of file