Skip to content

Instantly share code, notes, and snippets.

@tk0miya
Created February 8, 2013 11:06
Show Gist options
  • Save tk0miya/4738170 to your computer and use it in GitHub Desktop.
Save tk0miya/4738170 to your computer and use it in GitHub Desktop.
Setup rbenv and Ruby using capistrano-rbenv. To install them, use "cap deploy:setup" !
# rbenv setting
require 'capistrano-rbenv'
set :rbenv_ruby_version, '1.9.3-p374'
namespace :rbenv do
task :setup_shellenv do
set :default_environment, {
'RBENV_ROOT' => "#{rbenv_path}",
'PATH' => "#{rbenv_path}/shims:#{rbenv_path}/bin:$PATH"
}
end
after 'multistage:ensure', 'rbenv:setup_shellenv'
desc "Install build dependencies of Ruby (for CentOS 5.x)"
task :install_build_depends do
rpms = %w(http://dl.fedoraproject.org/pub/epel/5/x86_64/perl-Error-0.17010-1.el5.noarch.rpm
http://dl.fedoraproject.org/pub/epel/5/x86_64/perl-Git-1.7.4.1-1.el5.x86_64.rpm
http://dl.fedoraproject.org/pub/epel/5/x86_64/git-1.7.4.1-1.el5.x86_64.rpm
http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/autoconf26x-2.63-4.ius.el5.noarch.rpm)
filenames = []
rpms.each do |url|
filename = "/tmp/#{File.basename(url)}"
run "wget -O #{filename} #{url}"
filenames << filename
end
run "#{sudo} rpm -ivh #{filenames.join(" ")} || true"
run "rm #{filenames.join(" ")}"
end
before 'rbenv:setup', 'rbenv:install_build_depends'
desc "Initialize rbenv (applying installed gems)"
task :init do
run "rbenv init - | sh"
end
after 'roundsman:chef:install', 'rbenv:init'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment