Skip to content

Commit

Permalink
Merge branch 'master' into passenger-nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelglass committed Jun 22, 2011
2 parents 247d490 + 10d4343 commit c96dedc
Show file tree
Hide file tree
Showing 23 changed files with 127 additions and 92 deletions.
41 changes: 41 additions & 0 deletions CHANGELOG
@@ -1,3 +1,44 @@
1.14.1 (06/02/2011)
-----

Upgraded the version of RVM installed by default
Switched from using our own installation method to using the new RVM installer

1.14.0 (06/02/2011)
-----

Projects using bundler will now run rake with bundle exec
Added ability to lockdown the version of rake that RVM will install (vulcanize base for the changes)
Added the image type and ID for each instance to the instance file
Fixed an issue with LVM groups keeping physical volumes in /etc/fstab
Fixed an issue using the mysql2 adapter with the stock MySQL config
Disable ri and rdoc generation on new hosts

1.13.2
-----

fix npe <184cbac> [Matt Conway]
Merge pull request #61 from dzinevich/e173588f4018bc118785bd3806d262ce3bdd033d <0bfb5c2> [Kevin Menard]
make workaround so ebs works with 11.04 <e173588> [Denis Zinevich]

1.13.1
-----

allow specifying a common role dependency for all instances <f49b662> [Matt Conway]
allow one to specify HOSTand ROLES when testing rake rubber:config in dev <56b3c8c> [Matt Conway]
Merged pull request #57 from drync/no_rvmrc. <9aee319> [Matt Conway]
Exclude .rvmrc from NO_SCM deploys <3fa1502> [Savanah Cummings]

1.13.0
-----

Forgot target roles for start/stop/restart <9b916e8> [Alex Kremer]
Fix enabling multiverse on newer canonical AMIs (ie Maverick) <dcf81fa> [Alex Kremer]
Initial commit of MongoDB Template <c4f7640> [Alex Kremer]
allow FORCE on destroy_all <0db9347> [Matt Conway]
Removing a function that wasn't meant to be committed :( <8538041> [Jordan Brock]
Added support for changing the region end point, using the EC2 gem "server" key. <326448f> [Jordan Brock]

1.13.0
-----

Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
1.13.0
1.14.1
2 changes: 1 addition & 1 deletion lib/generators/vulcanize/templates/base/config/deploy.rb
Expand Up @@ -6,7 +6,7 @@
set :application, rubber_env.app_name
set :runner, rubber_env.app_user
set :deploy_to, "/mnt/#{application}-#{RUBBER_ENV}"
set :copy_exclude, [".git/*", ".bundle/*", "log/*"]
set :copy_exclude, [".git/*", ".bundle/*", "log/*", ".rvmrc"]
end

# Use a simple directory tree copy here to make demo easier.
Expand Down
Expand Up @@ -7,41 +7,27 @@
task :install_rvm do
rubber.sudo_script "install_rvm", <<-ENDSCRIPT
if [[ ! `rvm --version 2> /dev/null` =~ "#{rubber_env.rvm_version}" ]]; then
echo "rvm_prefix=/usr/local/" > /etc/rvmrc
echo "#{rubber_env.rvm_prepare}" > /etc/profile.d/rvm.sh
# Copied below from http://rvm.beginrescueend.com/releases/rvm-install-latest
#
if [[ -f /etc/rvmrc ]] ; then source /etc/rvmrc ; fi
if [[ -f "$HOME/.rvmrc" ]] ; then source "$HOME/.rvmrc" ; fi
rvm_path="${rvm_path:-$HOME/.rvm}"
mkdir -p $rvm_path/src/
builtin cd $rvm_path/src
stable_version=#{rubber_env.rvm_version}
echo "rvm-${stable_version}"
curl -L "http://rvm.beginrescueend.com/releases/rvm-${stable_version}.tar.gz" -o "rvm-${stable_version}.tar.gz"
tar zxf "rvm-${stable_version}.tar.gz"
builtin cd "rvm-${stable_version}"
dos2unix scripts/* >/dev/null 2>&1 || true
bash ./scripts/install
cd /tmp
curl -s https://rvm.beginrescueend.com/install/rvm -o rvm-installer
chmod +x rvm-installer
rm -f /etc/rvmrc
rvm_path=#{rubber_env.rvm_prefix} ./rvm-installer --version #{rubber_env.rvm_version}
# Set up the rubygems version
sed -i 's/rubygems_version=.*/rubygems_version=#{rubber_env.rubygems_version}/' #{rubber_env.rvm_prefix}/config/db
#
# end rvm install script
# Set up the rake version
sed -i 's/rake.*/rake -v#{rubber_env.rake_version}/' #{rubber_env.rvm_prefix}/gemsets/default.gems
sed -i 's/rake.*/rake -v#{rubber_env.rake_version}/' #{rubber_env.rvm_prefix}/gemsets/global.gems
# Set up the .gemrc file
if [[ ! -f ~/.gemrc ]]; then
echo "--- " >> ~/.gemrc
fi
if ! grep -q 'gem: ' ~/.gemrc; then
echo "gem: --no-ri --no-rdoc" >> ~/.gemrc
fi
fi
ENDSCRIPT
end
Expand Down
@@ -1,4 +1,3 @@

# rvm needs some extra packages to compile/install ruby runtimes
# curl is required.
# patch is required (for ree, some ruby head's).
Expand All @@ -12,7 +11,7 @@
packages: [build-essential, git-core, subversion, curl, autoconf, bison, ruby, zlib1g-dev, libssl-dev, libreadline5-dev, libxml2-dev]

# REQUIRED: the version of rvm itself
rvm_version: 1.2.7
rvm_version: 1.6.18

# REQUIRED: Set to the rvm version string for the ruby version you wish to use
# Run "rvm list known" to see the list of possible options
Expand All @@ -22,6 +21,9 @@ rvm_ruby: 1.9.2
# know about newer RubyGems. So you may need to bump your rvm_version to get the latest RubyGems release.
rubygems_version: 1.5.2

# REQUIRED: Set to version of rake you want RVM to install.
rake_version: 0.8.7

# When rvm is installed as root, and you set the default, it symlinks ruby executables
# into /usr/local/rvm
ruby_prefix: /usr/local/rvm
Expand Down
Expand Up @@ -5,4 +5,4 @@ check process haproxy with pidfile /var/run/haproxy.pid
group haproxy-<%= RUBBER_ENV %>
start program = "/usr/bin/env service haproxy start"
stop program = "/usr/bin/env service haproxy stop"
if failed host <%= rubber_env.host %> port <%= rubber_env.haproxy_monitor_port %> with timeout 10 seconds for 10 cycles then restart
if failed host "<%= rubber_env.host %>" port <%= rubber_env.haproxy_monitor_port %> with timeout 10 seconds for 10 cycles then restart
Expand Up @@ -3,7 +3,7 @@
%>

<%= RUBBER_ENV %>:
adapter: mysql
adapter: <%= YAML::load(File.open("#{RUBBER_ROOT}/config/database.yml"))["production"]["adapter"] %>
encoding: utf8
database: <%= rubber_env.db_name %>
username: <%= rubber_env.db_user %>
Expand Down
Expand Up @@ -5,7 +5,7 @@
# Sets up rails to talk to mysql-proxy load balancer running on localhost,
# which then then balances requests between sql nodes in the cluster
<%= RUBBER_ENV %>:
adapter: mysql
adapter: <%= YAML::load(File.open("#{RUBBER_ROOT}/config/database.yml"))["production"]["adapter"] %>
encoding: utf8
database: <%= rubber_env.db_name %>
username: <%= rubber_env.db_user %>
Expand Down
Expand Up @@ -13,7 +13,7 @@
# when variable interpolation of rvm_gem_home is run remotely, and since we
# are in cap, we run the interpolation locally
#
passenger_lib=$(find /usr/local/rvm -path "*/passenger-#{rubber_env.passenger_version}/*/mod_passenger.so" 2> /dev/null)
passenger_lib=$(find /usr/local/rvm/gems/`rvm current` -path "*/passenger-#{rubber_env.passenger_version}/*/mod_passenger.so" 2> /dev/null)
if [[ -z $passenger_lib ]]; then
echo -en "\n\n\n\n" | passenger-install-apache2-module
rvm #{rubber_env.rvm_ruby} --passenger
Expand Down
@@ -1,4 +1,4 @@
passenger_version: 3.0.4
passenger_version: 3.0.7
passenger_root: "#{rvm_gem_home}/gems/passenger-#{passenger_version}"
passenger_ruby: "#{rvm_prefix}/wrappers/#{`bash -l -c 'rvm strings #{rvm_ruby}'`.strip}/ruby"
passenger_lib: "#{passenger_root}/ext/apache2/mod_passenger.so"
Expand Down
Expand Up @@ -7,7 +7,7 @@

before "rubber:install_packages", "rubber:postgresql:setup_apt_sources"

task :setup_apt_sources, :roles => [:postgresql_master, :postgresql_save] do
task :setup_apt_sources do
rsudo "add-apt-repository ppa:pitti/postgresql"
end

Expand Down
@@ -1,4 +1,4 @@
redis_server_version: 2.2.1
redis_server_version: 2.2.8

redis_db_dir: /mnt/redis

Expand Down
Expand Up @@ -72,7 +72,7 @@

# runs the given ultrasphinx rake tasks
def run_sphinx task
rsudo "cd #{current_path} && RAILS_ENV=#{RUBBER_ENV} rake #{task}", :as => runner
rsudo "cd #{current_path} && RAILS_ENV=#{RUBBER_ENV} #{fetch(:rake, 'rake')} #{task}", :as => runner
end


Expand Down
Expand Up @@ -2,8 +2,8 @@
@path = '/etc/monit/monit.d/monit-sphinx.conf'

pidfile = "#{RUBBER_ROOT}/log/searchd.#{RUBBER_ENV}.pid"
start_program = "cd #{RUBBER_ROOT} && rake ts:start"
stop_program = "cd #{RUBBER_ROOT} && rake ts:stop"
start_program = "cd #{RUBBER_ROOT} && #{fetch(:rake, 'rake')} ts:start"
stop_program = "cd #{RUBBER_ROOT} && #{fetch(:rake, 'rake')} ts:stop"
%>

check process sphinx with pidfile <%= pidfile %>
Expand Down
13 changes: 11 additions & 2 deletions lib/rubber/instance.rb
Expand Up @@ -114,19 +114,21 @@ def size

# The configuration for a single instance
class InstanceItem
attr_reader :name, :domain, :instance_id, :security_groups
attr_reader :name, :domain, :instance_id, :image_type, :image_id, :security_groups
attr_accessor :roles, :zone
attr_accessor :external_host, :external_ip
attr_accessor :internal_host, :internal_ip
attr_accessor :static_ip, :volumes, :partitions, :root_device_type
attr_accessor :spot_instance_request_id
attr_accessor :platform

def initialize(name, domain, roles, instance_id, security_group_list=[])
def initialize(name, domain, roles, instance_id, image_type, image_id, security_group_list=[])
@name = name
@domain = domain
@roles = roles
@instance_id = instance_id
@image_type = image_type
@image_id = image_id
@security_groups = security_group_list
end

Expand Down Expand Up @@ -155,13 +157,20 @@ class RoleItem

def self.expand_role_dependencies(roles, dependency_map, expanded=[])
roles = Array(roles)

if expanded.size == 0
common_deps = Array(dependency_map[RoleItem.new('common')])
roles.concat(common_deps)
end

roles.each do |role|
unless expanded.include?(role)
expanded << role
needed = dependency_map[role]
expand_role_dependencies(needed, dependency_map, expanded)
end
end

return expanded
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rubber/recipes/rubber/deploy.rb
Expand Up @@ -84,7 +84,7 @@ def run_config(options={})
put(File.read(secret), File.join(path, base, File.basename(secret)), :mode => "+r")
end

rsudo "cd #{path} && #{extra_env} rake rubber:config"
rsudo "cd #{path} && #{extra_env} #{fetch(:rake, 'rake')} rubber:config"
end

end
2 changes: 1 addition & 1 deletion lib/rubber/recipes/rubber/instances.rb
Expand Up @@ -295,7 +295,7 @@ def create_instance(instance_alias, instance_roles, create_spot_instance)

logger.info "Instance #{instance_alias} created: #{instance_id}"

instance_item = Rubber::Configuration::InstanceItem.new(instance_alias, env.domain, instance_roles, instance_id, security_groups)
instance_item = Rubber::Configuration::InstanceItem.new(instance_alias, env.domain, instance_roles, instance_id, ami_type, ami, security_groups)
instance_item.spot_instance_request_id = request_id if create_spot_instance
rubber_instances.add(instance_item)
rubber_instances.save()
Expand Down
22 changes: 2 additions & 20 deletions lib/rubber/recipes/rubber/setup.rb
@@ -1,3 +1,5 @@
require "bundler/capistrano" if Rubber::Util.is_bundler?

namespace :rubber do

desc <<-DESC
Expand Down Expand Up @@ -257,26 +259,6 @@ def direct_connection(ip)
gem_helper(false)
end

desc <<-DESC
Install ruby gems defined in Gemfile
DESC
after "deploy:update_code", "rubber:install_bundler_gems" if Rubber::Util.is_bundler?
task :install_bundler_gems do
# copied from bundler/capistrano in bundler distro
bundle_dir = fetch(:bundle_dir, " #{fetch(:shared_path)}/bundle")
bundle_without = [*fetch(:bundle_without, [:development, :test])].compact
bundle_flags = fetch(:bundle_flags, "--deployment --quiet")
bundle_gemfile = fetch(:bundle_gemfile, "Gemfile")
bundle_cmd = fetch(:bundle_cmd, "bundle")

args = ["--gemfile #{fetch(:latest_release)}/#{bundle_gemfile}"]
args << "--path #{bundle_dir}" unless bundle_dir.to_s.empty?
args << bundle_flags.to_s
args << "--without #{bundle_without.join(" ")}" unless bundle_without.empty?

rsudo "#{bundle_cmd} install #{args.join(' ')}"
end

desc <<-DESC
Install ruby gems defined in the rails environment.rb
DESC
Expand Down
2 changes: 2 additions & 0 deletions lib/rubber/recipes/rubber/static_ips.rb
Expand Up @@ -134,6 +134,7 @@
# First half of the sync.
new_receiver = Rubber::Configuration::InstanceItem.new(old_receiver.name,
old_receiver.domain, old_receiver.roles, old_receiver.instance_id,
old_receiver.image_type, old_receiver.image_id,
old_receiver.security_groups)
new_receiver.static_ip = static_ip
rubber_instances.add(new_receiver)
Expand All @@ -153,6 +154,7 @@
# Second half of the sync.
new_donor = Rubber::Configuration::InstanceItem.new(old_donor.name,
old_donor.domain, old_donor.roles, old_donor.instance_id,
old_donor.image_type, old_donor.image_id,
old_donor.security_groups)
rubber_instances.add(new_donor)

Expand Down
23 changes: 17 additions & 6 deletions lib/rubber/recipes/rubber/volumes.rb
Expand Up @@ -124,9 +124,14 @@ def setup_volume(ic, vol_spec)
fi
mv /etc/fstab /etc/fstab.bak
cat /etc/fstab.bak | grep -v '#{vol_spec['mount']}' > /etc/fstab
echo '#{vol_spec['device']} #{vol_spec['mount']} #{vol_spec['filesystem']} noatime 0 0 # rubber volume #{vol_id}' >> /etc/fstab
#{('yes | mkfs -t ' + vol_spec['filesystem'] + ' ' + vol_spec['device']) if created}
if grep '11\.04' /etc/lsb-release; then
device=`echo #{vol_spec['device']} | sed 's/sd/xvd/'`
else
device='#{vol_spec['device']}'
fi
echo "$device #{vol_spec['mount']} #{vol_spec['filesystem']} noatime 0 0 # rubber volume #{vol_id}" >> /etc/fstab
#{('yes | mkfs -t ' + vol_spec['filesystem'] + ' ' + '$device') if created}
#{("mkdir -p '#{vol_spec['mount']}'") if vol_spec['mount']}
#{("mount '#{vol_spec['mount']}'") if vol_spec['mount']}
fi
Expand Down Expand Up @@ -157,7 +162,7 @@ def setup_partition(ic, partition_spec)
fi
# partition format is: Start (blank is first available),Size(MB due to -uM),Id(83=linux,82=swap,etc),Bootable
echo "#{partition_spec['start']},#{partition_spec['size']},#{partition_spec['type']},#{partition_spec['bootable']}" | sfdisk -L -uM #{partition_spec['disk_device']}
echo "#{partition_spec['start']},#{partition_spec['size']},#{partition_spec['type']},#{partition_spec['bootable']}" | sfdisk -L -uM #{partition_spec['disk_device']}
fi
ENDSCRIPT
end
Expand Down Expand Up @@ -216,12 +221,12 @@ def setup_raid_volume(ic, raid_spec, create=false)

task :_setup_raid_volume, :hosts => ic.external_ip do
rubber.sudo_script 'setup_raid_volume', <<-ENDSCRIPT
if ! grep -q '#{raid_spec['device']}' /etc/fstab; then
if ! grep -qE '#{raid_spec['device']}|#{raid_spec['mount']}' /etc/fstab; then
if mount | grep -q '#{raid_spec['mount']}'; then
umount '#{raid_spec['mount']}'
fi
mv /etc/fstab /etc/fstab.bak
cat /etc/fstab.bak | grep -v '#{raid_spec['mount']}' > /etc/fstab
cat /etc/fstab.bak | grep -vE '#{raid_spec['device']}|#{raid_spec['mount']}' > /etc/fstab
echo '#{raid_spec['device']} #{raid_spec['mount']} #{raid_spec['filesystem']} noatime 0 0 # rubber raid volume' >> /etc/fstab
# seems to help devices initialize, otherwise mdadm fails because
Expand Down Expand Up @@ -320,10 +325,16 @@ def create_logical_volume_in_bash(volume, volume_group_name)
for device in #{physical_volumes.join(' ')}
do
if ! pvdisplay $device >> /dev/null 2>&1; then
if grep $device /etc/mtab; then
umount $device
fi
if grep -q "$device" /etc/fstab; then
mv /etc/fstab /etc/fstab.bak
cat /etc/fstab.bak | grep -v "$device\\b" > /etc/fstab
fi
pvcreate $device
# See if the volume group already exists. If so, add the new physical volume to it.
Expand Down

0 comments on commit c96dedc

Please sign in to comment.