Skip to content

Commit

Permalink
Unifying riak and riak_eds cookbooks
Browse files Browse the repository at this point in the history
  • Loading branch information
Seth Thomas committed Jun 6, 2013
1 parent d89d211 commit bcf4f83
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 101 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ Source Installation

The riak::source recipe can be used to install Riak from source. The source installation requires the build-essential and erlang cookbooks.

Enterprise Installation
-------------------

To install Riak Enterprise populate the following attribute with a Basho provided key:

node['riak']['package']['enterprise_key']


Basic Configuration
-------------------
Expand Down
58 changes: 35 additions & 23 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
# 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"
default['riak']['bin_dir'] = "/usr/sbin"
default['riak']['data_dir'] = "/var/lib/riak"
default['riak']['etc_dir'] = "/etc/riak"
default['riak']['lib_dir'] = "/usr/lib/riak"
default['riak']['log_dir'] = "/var/log/riak"

# vm.args
default['riak']['args']['-name'] = "riak@#{node['fqdn']}"
Expand All @@ -31,12 +31,12 @@
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'] = "#{platform_log_dir}/erl_crash.dump"
default['riak']['args']['-env']['ERL_CRASH_DUMP'] = "#{node['riak']['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\""
#default['riak']['args']['-ssl_dist_opt']['client_certfile'] = "\"#{node['riak']['etc_dir']}/erlclient.pem\""
#default['riak']['args']['-ssl_dist_opt']['server_certfile'] = "\"#{node['riak']['etc_dir']}/erlserver.pem\""

# app.config
class ::String
Expand All @@ -57,7 +57,7 @@ class ::Array
default['riak']['config']['riak_api']['pb_port'] = 8087

# riak_core
default['riak']['config']['riak_core']['ring_state_dir'] = "#{platform_data_dir}/ring".to_erl_string
default['riak']['config']['riak_core']['ring_state_dir'] = "#{node['riak']['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]
Expand All @@ -66,19 +66,19 @@ class ::Array
#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']['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
default['riak']['config']['riak_core']['platform_bin_dir'] = node['riak']['bin_dir'].to_erl_string
default['riak']['config']['riak_core']['platform_data_dir'] = node['riak']['data_dir'].to_erl_string
default['riak']['config']['riak_core']['platform_etc_dir'] = node['riak']['etc_dir'].to_erl_string
default['riak']['config']['riak_core']['platform_lib_dir'] = node['riak']['lib_dir'].to_erl_string
default['riak']['config']['riak_core']['platform_log_dir'] = node['riak']['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_data_dir'] = "#{node['riak']['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"
Expand All @@ -100,9 +100,9 @@ class ::Array
case node['riak']['config']['riak_kv']['storage_backend']
when "riak_kv_bitcask_backend"
default['riak']['config']['bitcask']['io_mode'] = "erlang"
default['riak']['config']['bitcask']['data_root'] = "#{platform_data_dir}/bitcask".to_erl_string
default['riak']['config']['bitcask']['data_root'] = "#{node['riak']['data_dir']}/bitcask".to_erl_string
when "riak_kv_eleveldb_backend"
default['riak']['config']['eleveldb']['data_root'] = "#{platform_data_dir}/leveldb".to_erl_string
default['riak']['config']['eleveldb']['data_root'] = "#{node['riak']['data_dir']}/leveldb".to_erl_string
when "riak_kv_multi_backend"
default['riak']['config']['riak_kv']['multi_backend_default'] = "bitcask_mult"
bitcask_mult = ["bitcask_mult", "riak_kv_bitcask_backend", {"data_root" => "#{platform_data_dir}/bitcask".to_erl_string}]
Expand All @@ -118,24 +118,24 @@ class ::Array
prefix_list = ["0b:".to_erl_binary, "be_blocks"]
default['riak']['config']['riak_kv']['multi_backend_prefix_list'] = [prefix_list.to_erl_tuple]
default['riak']['config']['riak_kv']['multi_backend_default'] = "be_default"
be_default = ["be_default", "riak_kv_eleveldb_backend", {"data_root" => "#{platform_data_dir}/leveldb".to_erl_string, "max_open_files" => 50}]
be_blocks = ["be_blocks", "riak_kv_bitcask_backend", {"data_root" => "#{platform_data_dir}/bitcask".to_erl_string}]
be_default = ["be_default", "riak_kv_eleveldb_backend", {"data_root" => "#{node['riak']['data_dir']}/leveldb".to_erl_string, "max_open_files" => 50}]
be_blocks = ["be_blocks", "riak_kv_bitcask_backend", {"data_root" => "#{node['riak']['data_dir']}/bitcask".to_erl_string}]
default['riak']['config']['riak_kv']['multi_backend'] = [be_default.to_erl_tuple, be_blocks.to_erl_tuple]
end

# riak_search
default['riak']['config']['riak_search']['enabled'] = false

# merge_index
default['riak']['config']['merge_index']['data_root'] = "#{platform_data_dir}/merge_index".to_erl_string
default['riak']['config']['merge_index']['data_root'] = "#{node['riak']['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 = ["#{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
error_log = ["#{node['riak']['log_dir']}/error.log".to_erl_string,"error",10485760,"$D0".to_erl_string,5].to_erl_tuple
info_log = ["#{node['riak']['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'] = "#{platform_log_dir}/crash.log".to_erl_string
default['riak']['config']['lager']['crash_log'] = "#{node['riak']['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
Expand All @@ -160,6 +160,18 @@ class ::Array
default['riak']['config']['riak_control']['userlist'] = [["user".to_erl_string,"pass".to_erl_string].to_erl_tuple]
default['riak']['config']['riak_control']['admin'] = true

# riak_repl
default['riak']['config']['riak_repl']['data_root'] = "#{node['riak']['data_dir']}/riak_repl".to_erl_string

#jmx config options
default['riak']['config']['riak_jmx']['enabled'] = false

#snmp config options
default['riak']['config']['snmp']['agent']['net_if']['options']['bind_to'] = true
default['riak']['config']['snmp']['agent']['config']['dir'] = "#{node['riak']['etc_dir']}/snmp/agent/conf".to_erl_string
default['riak']['config']['snmp']['agent']['config']['force_load'] = true
default['riak']['config']['snmp']['agent']['db_dir'] = "#{node['riak']['data_dir']}/snmp/agent/db".to_erl_string

# limits
default['riak']['limits']['nofile'] = 4096

Expand Down
4 changes: 2 additions & 2 deletions attributes/monit.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
default['riak']['monit']['process_matching'] = "/usr/lib/riak/erts-5.8.5/bin/beam.smp"
default['riak']['monit']['start_program'] = "/usr/sbin/riak"
default['riak']['monit']['process_matching'] = "#{node['riak']['data_dir']}/erts-5.8.5/bin/beam.smp"
default['riak']['monit']['start_program'] = "#{node['riak']['bin_dir']}/riak"
default['riak']['monit']['http_host'] = "localhost"
default['riak']['monit']['http_port'] = "8098"
2 changes: 1 addition & 1 deletion attributes/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
default['riak']['package']['enterprise_key'] = false

default['riak']['package']['url'] = "http://s3.amazonaws.com/downloads.basho.com/riak"
default['riak']['package']['version']['major'] = "1"
Expand All @@ -25,5 +26,4 @@
default['riak']['package']['config_dir'] = "/etc/riak"
default['riak']['package']['local_package'] = false

default['riak']['package']['checksum']['fedora']['17'] = "fff0f7f2033a09cb721f3e438ddeb2f35d474df6ea900f3a6fbe4882e5d2d9e9"
default['riak']['package']['checksum']['local'] = nil
4 changes: 2 additions & 2 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Author:: Benjamin Black (<[email protected]>) and Sean Cribbs (<[email protected]>)
# Author:: Benjamin Black (<[email protected]>), Sean Cribbs (<sean@basho.com>), Seth Thomas (<sthomas@basho.com>)
# Cookbook Name:: riak
#
# Copyright (c) 2013 Basho Technologies, Inc.
Expand All @@ -22,7 +22,7 @@
maintainer_email "[email protected]"
license "Apache 2.0"
description "Installs and configures Riak distributed data store"
version "2.0.1"
version "2.1.0"

recipe "riak", "Installs Riak from a package"
recipe "riak::source", "Installs Erlang and Riak from source"
Expand Down
75 changes: 3 additions & 72 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,79 +19,10 @@
#
include_recipe "ulimit"

version_str = "#{node['riak']['package']['version']['major']}.#{node['riak']['package']['version']['minor']}"
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['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
if node['riak']['package']['enterprise_key'] == false
include_recipe "riak::package"
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 "riak" do
action :install
end

when "centos", "redhat"
include_recipe "yum"

yum_key "RPM-GPG-KEY-basho" do
url "http://yum.basho.com/gpg/RPM-GPG-KEY-basho"
action :add
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

package "riak" do
action :install
end

when "fedora"

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

package package_name do
source "#{Chef::Config[:file_cache_path]}/#{package_file}"
action :install
end
end
include_recipe "riak::enterprise_package"
end

file "#{node['riak']['package']['config_dir']}/app.config" do
Expand Down
91 changes: 91 additions & 0 deletions recipes/enterprise_package.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#
# Author:: Benjamin Black (<[email protected]>) and Sean Cribbs (<[email protected]>) and Seth Thomas (<[email protected]>)
# Cookbook Name:: riak
# Recipe:: enterprise_package
#
# 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.
#

version_str = "#{node['riak']['package']['version']['major']}.#{node['riak']['package']['version']['minor']}.#{node['riak']['package']['version']['incremental']}"
base_uri = "http://private.downloads.basho.com/riak_ee/#{node['riak']['package']['enterprise_key']}/#{version_str}/"
base_filename = "riak-ee-#{version_str}"

case node['platform']
when "ubuntu"
machines = {"x86_64" => "amd64", "i386" => "i386", "i686" => "i386"}
#checksum_val = node['riak']['package']['checksum']['ubuntu'][node['lsb']['codename']][node['kernel']['machine']]
base_uri = "#{base_uri}#{node['platform']}/#{node['lsb']['codename']}/"
package "libssl0.9.8"
package_file = "#{base_filename.gsub(/\-/, '_').sub(/_/,'-')}-#{node['riak']['package']['version']['build']}_#{machines[node['kernel']['machine']]}.deb"
when "debian"
machines = {"x86_64" => "amd64", "i386" => "i386", "i686" => "i386"}
#checksum_val = node['riak']['package']['checksum']['debian'][node['platform_version']]
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"}
#checksum_val = node['riak']['package']['checksum']['rhel'][node['platform_version']]
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.set['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"}
#checksum_val = node['riak']['package']['checksum']['fedora'][node['platform_version']]
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.set['riak']['config']['riak_core']['platform_lib_dir'] = "/usr/lib64/riak".to_erl_string if node['kernel']['machine'] == 'x86_64'
end

package_uri = base_uri + package_file
package_name = package_file.split("[-_]\d+\.").first

group "riak"

user "riak" do
gid "riak"
shell "/bin/bash"
home "/var/lib/riak"
system true
end

if node['riak']['package']['local_package'] == false
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
else
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
end

package package_name do
source "#{Chef::Config[:file_cache_path]}/#{package_file}"
action :install
case node['platform'] when "ubuntu","debian"
options "--force-confdef --force-confold"
end
provider value_for_platform(
[ "ubuntu", "debian" ] => {"default" => Chef::Provider::Package::Dpkg},
[ "redhat", "centos", "fedora" ] => {"default" => Chef::Provider::Package::Yum}
)
end
Loading

0 comments on commit bcf4f83

Please sign in to comment.