Permalink
Browse files

[dev_setup] add warden support

wardenize for below service components:
vblob
redis
mongodb
rabbitmq

Change-Id: I2370ac8785b321e47534553474310f8cb2bdca90
  • Loading branch information...
Haipeng Wu
Haipeng Wu committed Sep 6, 2012
1 parent 9d1fe38 commit e6952085121fb75458ba8dce12ac8b26a5f62cb2
Showing with 487 additions and 102 deletions.
  1. +3 −0 .gitmodules
  2. +22 −2 dev_setup/bin/vcap_dev_setup
  3. +16 −7 dev_setup/cookbooks/mongodb/recipes/default.rb
  4. +48 −0 dev_setup/cookbooks/mongodb/templates/default/mongod_startup.sh.erb
  5. +25 −0 dev_setup/cookbooks/mongodb/templates/default/mongodb.conf.erb
  6. +3 −0 dev_setup/cookbooks/mongodb/templates/default/mongodb_node.yml.erb
  7. +3 −0 dev_setup/cookbooks/mongodb/templates/default/mongodb_worker.yml.erb
  8. +1 −0 dev_setup/cookbooks/nats_server/recipes/default.rb
  9. +9 −2 dev_setup/cookbooks/rabbitmq/attributes/default.rb
  10. +27 −16 dev_setup/cookbooks/rabbitmq/recipes/default.rb
  11. +3 −0 dev_setup/cookbooks/rabbitmq/templates/default/rabbitmq_node.yml.erb
  12. +25 −0 dev_setup/cookbooks/rabbitmq/templates/default/rabbitmq_startup.sh.erb
  13. +8 −8 dev_setup/cookbooks/redis/attributes/default.rb
  14. +37 −29 dev_setup/cookbooks/redis/recipes/default.rb
  15. +0 −12 dev_setup/cookbooks/redis/templates/default/redis.conf.erb
  16. +3 −1 dev_setup/cookbooks/redis/templates/default/redis_node.yml.erb
  17. +9 −0 dev_setup/cookbooks/redis/templates/default/redis_startup.sh.erb
  18. +3 −1 dev_setup/cookbooks/redis/templates/default/redis_worker.yml.erb
  19. +0 −5 dev_setup/cookbooks/ruby/libraries/ruby_install.rb
  20. +1 −1 dev_setup/cookbooks/vblob/attributes/default.rb
  21. +16 −12 dev_setup/cookbooks/vblob/recipes/default.rb
  22. +3 −1 dev_setup/cookbooks/vblob/templates/default/vblob_node.yml.erb
  23. +13 −0 dev_setup/cookbooks/vblob/templates/default/vblob_startup.sh.erb
  24. +7 −0 dev_setup/cookbooks/warden/README.rdoc
  25. +2 −0 dev_setup/cookbooks/warden/attributes/default.rb
  26. +6 −0 dev_setup/cookbooks/warden/metadata.rb
  27. +50 −0 dev_setup/cookbooks/warden/recipes/default.rb
  28. +12 −0 dev_setup/cookbooks/warden/recipes/start.rb
  29. +8 −0 dev_setup/cookbooks/warden/templates/default/services.conf.erb
  30. +64 −0 dev_setup/cookbooks/warden/templates/default/warden_server.conf.erb
  31. +46 −0 dev_setup/cookbooks/warden/templates/default/warden_server.erb
  32. +3 −1 dev_setup/roles/mongodb_node.json
  33. +3 −1 dev_setup/roles/rabbitmq_node.json
  34. +3 −1 dev_setup/roles/redis_node.json
  35. +3 −1 dev_setup/roles/vblob_node.json
  36. +1 −1 services
  37. +1 −0 warden
View
@@ -10,3 +10,6 @@
[submodule "acm"]
path = acm
url = https://github.com/cloudfoundry/acm.git
+[submodule "warden"]
+ path = warden
+ url = https://github.com/cloudfoundry/warden.git
@@ -100,6 +100,27 @@ if [ -z "$VCAP_REPO_BRANCH" ]; then
VCAP_REPO_BRANCH=master
fi
+# check if need to install warden
+[ -z "${CONFIG_FILE}" ] && config="$CLOUDFOUNDRY_HOME/vcap/dev_setup/deployments/devbox.yml" || config="${CONFIG_FILE}"
+if grep "_node" ${config} > /dev/null && [ `uname -r` \< "2.6.38" ]; then
+ echo ""
+ echo "Warning, it is detected that some service compoents will be deployed, and linux kernel need to be upgraded"
+ echo "To continue the deployment, please follow the steps below"
+ echo " sudo apt-get install -y linux-image-generic-lts-backport-natty"
+ echo " reboot system"
+ echo " re-run vcap_dev_setup"
+ echo ""
+ exit
+fi
+
+# sudo with no passwd
+me=`whoami`
+if ! sudo cat /etc/sudoers | grep "${me}.*NOPASSWD" > /dev/null 2>&1; then
+ sudo cat /etc/sudoers > /tmp/sudoers.new
+ sudo echo "${me} ALL=(ALL) NOPASSWD:ALL" >> /tmp/sudoers.new
+ sudo cp /tmp/sudoers.new /etc/sudoers
+fi
+
# apt-get update
run_cmd apt-get update
@@ -133,9 +154,8 @@ if [ ! -f ${GEM} ] || [ `${GEM} -v` \< "1.3.6" ]; then
cd ${CWD}
fi
-# FIXME: at some point you will want a version spec like "~> 10.12.0" here
echo "Installing chef..."
-${GEM} list -i chef || sudo ${GEM} install chef -q --no-ri --no-rdoc > /dev/null
+${GEM} list -i chef || sudo ${GEM} install chef --version 10.12.0 -q --no-ri --no-rdoc > /dev/null
# Install blobstore_client
echo "Installing blobstore_client..."
@@ -8,7 +8,7 @@
node[:mongodb][:supported_versions].each do |version, install_version|
Chef::Log.info("Building Mongo Version: #{version} - #{install_version}")
- install_path = File.join(node[:deployment][:home], "deploy", "mongodb", install_version)
+ install_path = File.join(node[:warden][:rootfs_path], "usr", "share", "mongodb", "mongodb-#{version}")
source_file_id, source_file_checksum = id_and_checksum_for_version(install_version)
mongodb_tarball_path = File.join(node[:deployment][:setup_cache], "mongodb-linux-#{node[:kernel][:machine]}-#{install_version}.tgz")
@@ -19,24 +19,33 @@
checksum source_file_checksum
end
- directory File.join(install_path, "bin") do
- owner node[:deployment][:user]
- group node[:deployment][:group]
+ directory File.join(install_path) do
mode "0755"
recursive true
action :create
end
bash "Install Mongodb #{version} (#{install_version})" do
cwd File.join("", "tmp")
- user node[:deployment][:user]
code <<-EOH
tar xvzf #{mongodb_tarball_path}
cd mongodb-linux-#{node[:kernel][:machine]}-#{install_version}
- cp #{File.join("bin", "*")} #{File.join(install_path, "bin")}
+ cp #{File.join("bin", "*")} #{File.join(install_path)}
EOH
not_if do
- ::File.exists?(File.join(install_path, "bin", "mongo"))
+ ::File.exists?(File.join(install_path, "mongo"))
end
end
end
+
+template "mongod_startup.sh" do
+ path File.join(node[:warden][:rootfs_path], "usr", "bin", "mongod_startup.sh")
+ source "mongod_startup.sh.erb"
+ mode 0755
+end
+
+template "mongodb.conf" do
+ path File.join(node[:warden][:rootfs_path], "etc", "mongodb.conf")
+ source "mongodb.conf.erb"
+ mode 0644
+end
@@ -0,0 +1,48 @@
+#!/bin/bash
+for n in `seq 1 100`; do
+ if [ -f /tmp/vcap_chown.out ]; then
+ break
+ fi
+ sleep 0.1
+done
+
+touch /store/log/mongodb.log
+mkdir -p /store/instance/data
+
+# mongod_startup.sh 1.8
+# mongod_startup.sh 1.8 --journal
+# mongod_startup.sh 2.0
+# mongod_startup.sh 2.0 --nojournal
+if [ $# -gt 0 ]; then
+ if [ $1 = "1.8" ]; then
+ params="--journal"
+ arguments=""
+
+ shift
+ while [ $# -ne 0 ]; do
+ for i in $params; do
+ if [ $1 = $i ]; then
+ arguments="$arguments $1"
+ fi
+ done
+ shift
+ done
+
+ exec /usr/share/mongodb/mongodb-1.8/mongod $arguments --config /etc/mongodb.conf
+ elif [ $1 = "2.0" ]; then
+ params="--nojournal"
+ arguments=""
+
+ shift
+ while [ $# -ne 0 ]; do
+ for i in $params; do
+ if [ $1 = $i ]; then
+ arguments="$arguments $1"
+ fi
+ done
+ shift
+ done
+
+ exec /usr/share/mongodb/mongodb-2.0/mongod $arguments --config /etc/mongodb.conf
+ fi
+fi
@@ -0,0 +1,25 @@
+dbpath = /store/instance/data
+logpath = /store/log/mongodb.log
+logappend = false # This doesn't works
+
+bind_ip = 0.0.0.0
+port = 27017
+
+auth = true
+
+nohttpinterface = true
+
+maxConns = 500
+
+# mms-token = 33f75ccb-ec85-4294-b6ec-e6ae7a63901f
+
+# journaling is currently preallocating 4G of space on disk
+# we can't do that.
+#
+#journal = true
+noprealloc = true
+
+# smallfiles = start first container file at 16MB, doubling 4 times.
+# so this = 240MB per user. (i.e. 16MB container + 32MB + 64MB + 128MB)
+#quota = true
+smallfiles = true
@@ -42,3 +42,6 @@ port_range:
migration_nfs: /mnt/migration
logging:
level: debug
+
+image_dir: /var/vcap/store/mongodb_image
+max_disk: 2048
@@ -41,3 +41,6 @@ port_range:
last: 45000
logging:
level: debug
+
+image_dir: /var/vcap/store/mongodb_image
+max_disk: 2048
@@ -7,6 +7,7 @@
gem_package "nats" do
gem_binary File.join(node[:ruby][:path], "bin", "gem")
+ version "0.4.26"
end
nats_config_dir = File.join(node[:deployment][:config_path], "nats_server")
@@ -9,8 +9,15 @@
default[:rabbitmq][:default_version] = "2.4"
default[:rabbitmq][:path] = File.join(node[:deployment][:home], "deploy", "rabbitmq")
-default[:rabbitmq][:id] = "eyJzaWciOiJOTWRVQm01RHU3c1RXcHF4dUovUm93S1c0UUU9Iiwib2lkIjoi%0ANGU0ZTc4YmNhNDFlMTIxMjA0ZTRlODZlZTUzOTIxMDUwMTlmYTU0YWRkZTEi%0AfQ==%0A"
-default[:rabbitmq][:checksum] = "0a87dfe4489b0ddabfee7306536530934a4d4518ef0821e08634c7a07d4cf732"
+default[:rabbitmq][:id] = {
+ "2.4.1" => "eyJzaWciOiJVOUo4bW9Kci9tSlY2VW84WG9sa1NVMEFMb0k9Iiwib2lkIjoi%0ANGU0ZTc4YmNhMTFlMTIxMDA0ZTRlN2Q1MTFmODIxMDUwNWE5N2EwZjI4MDUi%0AfQ==%0A"
+}
+default[:rabbitmq][:checksum] = {
+ "2.4.1" => "1cc8dbe3a54b7ef454adb3b6f3bce2f4c798e45ab1608b9600b2dc01a04e5858"
+}
+
+default[:rabbitmq][:erlang_id] = "eyJzaWciOiJIb2RpNmdVdnp0S2VHSGRtRUxYQ3dGWnc3WHM9Iiwib2lkIjoi%0ANGU0ZTc4YmNhMzFlMTIxMDA0ZTRlN2Q1MTQ3NDVmMDUwNTljZDgxMmY5YWMi%0AfQ==%0A"
+default[:rabbitmq][:erlang_checksum] = "4c72446596803e8a41ec06e7bee5e840d81756f25613bbe3042609c7d0cb0d6b"
default[:rabbitmq_gateway][:service][:timeout] = "15"
default[:rabbitmq_gateway][:node_timeout] = "10"
@@ -6,35 +6,46 @@
#
#
+template "rabbitmq_startup.sh" do
+ path File.join(node[:warden][:rootfs_path], "usr", "bin", "rabbitmq_startup.sh")
+ source "rabbitmq_startup.sh.erb"
+ mode 0755
+end
+
+rabbitmq_erlang_tarball_path = File.join(node[:deployment][:setup_cache], "rabbitmq-erlang.tar.gz")
+cf_remote_file rabbitmq_erlang_tarball_path do
+ owner node[:deployment][:user]
+ id node[:rabbitmq][:erlang_id]
+ checksum node[:rabbitmq][:erlang_checksum]
+end
+
+bash "Install Erlang for RabbitMQ" do
+ code <<-EOH
+ cd #{node[:warden][:rootfs_path]}/var/vcap/packages
+ tar xzf #{rabbitmq_erlang_tarball_path}
+ EOH
+end
+
node[:rabbitmq][:supported_versions].each do |version, install_version|
#TODO, need more refine to actually support mutiple versions
Chef::Log.info("Building rabbitmq version: #{version} - #{install_version}")
case node['platform']
when "ubuntu"
- package "erlang-nox"
-
- rabbitmq_tarball_path = File.join(node[:deployment][:setup_cache], "rabbitmq-server-with-plugins-generic-unix-#{install_version}.tar.gz")
+ rabbitmq_tarball_path = File.join(node[:deployment][:setup_cache], "rabbitmq-server-with-plugins-#{install_version}.tar.gz")
cf_remote_file rabbitmq_tarball_path do
owner node[:deployment][:user]
- id node[:rabbitmq][:id]
- checksum node[:rabbitmq][:checksum]
- end
-
- directory "#{node[:rabbitmq][:path]}" do
- owner node[:deployment][:user]
- group node[:deployment][:group]
- mode "0755"
+ id node[:rabbitmq][:id]["#{install_version}"]
+ checksum node[:rabbitmq][:checksum]["#{install_version}"]
end
bash "Install RabbitMQ" do
cwd File.join("", "tmp")
- user node[:deployment][:user]
code <<-EOH
- tar xzf #{rabbitmq_tarball_path}
- cd rabbitmq_server-#{install_version}
- cp -rf * #{node[:rabbitmq][:path]}
- EOH
+ tar xzf #{rabbitmq_tarball_path}
+ mkdir -p #{node[:warden][:rootfs_path]}/var/vcap/packages/rabbitmq/#{version}
+ cp -rf rabbitmq/* #{node[:warden][:rootfs_path]}/var/vcap/packages/rabbitmq/#{version}
+ EOH
end
else
@@ -23,3 +23,6 @@ max_clients: 1000
rabbitmq_log_dir: /var/vcap/services/rabbit/logs
rabbitmq_server: <%= File.join(node[:rabbitmq][:path], "sbin", "rabbitmq-server") %>
rabbitmq_start_timeout: <%= node[:rabbitmq_node][:rabbitmq_start_timeout] %>
+
+image_dir: /var/vcap/store/rabbitmq_image
+max_disk: 2048
@@ -0,0 +1,25 @@
+for n in `seq 1 100`; do
+ if [ -f /tmp/vcap_chown.out ]; then
+ break
+ fi
+ sleep 0.1
+done
+
+export ERLANG_HOME=/var/vcap/packages/erlang
+export PATH=/var/vcap/packages/erlang/bin:$PATH
+export HOME=/store/instance
+export RABBITMQ_NODENAME="$1@localhost"
+export RABBITMQ_NODE_PORT=10001
+export RABBITMQ_BASE=/store/instance
+export RABBITMQ_LOG_BASE=/store/log
+export RABBITMQ_MNESIA_DIR=/store/instance/mnesia
+export RABBITMQ_PLUGINS_EXPAND_DIR=/store/instance/plugins
+export RABBITMQ_CONFIG_FILE=/store/instance/config/rabbitmq
+export RABBITMQ_ENABLED_PLUGINS_FILE=/store/instance/config/enabled_plugins
+export RABBITMQ_SERVER_START_ARGS="-smp disable"
+export RABBITMQ_CONSOLE_LOG=reuse
+export ERL_CRASH_DUMP="/dev/null"
+export ERL_CRASH_DUMP_SECONDS="1"
+
+[ -z $2 ] && version=<%= node[:rabbitmq][:default_version] %> || version=$2
+exec start-stop-daemon --start --quiet --chuid vcap --exec /var/vcap/packages/rabbitmq/${version}/sbin/rabbitmq-server >/store/log/rabbitmq_${version}_stdout.log 2>/store/log/rabbitmq_${version}_stderr.log
@@ -3,12 +3,8 @@
include_attribute "backup"
include_attribute "service_lifecycle"
-default[:redis][:supported_versions] = {
- "2.2" => "2.2.15",
-}
-default[:redis][:version_aliases] = {
- "current" => "2.2",
-}
+default[:redis][:supported_versions] = { "2.2" => "2.2.15" }
+default[:redis][:version_aliases] = { "current" => "2.2" }
default[:redis][:default_version] = "2.2"
default[:redis][:path] = File.join(node[:deployment][:home], "deploy", "redis")
@@ -17,8 +13,12 @@
default[:redis][:password] = "redis"
default[:redis][:expire] = 60
-default[:redis][:id] = "eyJzaWciOiJ0akRiejV6Mk9aT2ZLcHlqdHJCaW1QbnJrVUk9Iiwib2lkIjoi%0ANGU0ZTc4YmNhNDFlMTIyMjA0ZTRlOTg2M2QwNzYzMDUwMTlmOGY5YzVkZjci%0AfQ==%0A"
-default[:redis][:checksum] = "4143b7fab809c5fe586265b4f792f346206a3a8082bbf79f70081a0538bab3cb"
+default[:redis][:id] = {
+ "2.2.15" => "eyJzaWciOiJ0akRiejV6Mk9aT2ZLcHlqdHJCaW1QbnJrVUk9Iiwib2lkIjoi%0ANGU0ZTc4YmNhNDFlMTIyMjA0ZTRlOTg2M2QwNzYzMDUwMTlmOGY5YzVkZjci%0AfQ==%0A"
+}
+default[:redis][:checksum] = {
+ "2.2.15" => "4143b7fab809c5fe586265b4f792f346206a3a8082bbf79f70081a0538bab3cb"
+}
default[:redis_gateway][:service][:timeout] = "15"
default[:redis_gateway][:node_timeout] = "5"
Oops, something went wrong.

0 comments on commit e695208

Please sign in to comment.