Skip to content

Instantly share code, notes, and snippets.

@kei2100
Created November 20, 2013 08:23
Show Gist options
  • Save kei2100/7559651 to your computer and use it in GitHub Desktop.
Save kei2100/7559651 to your computer and use it in GitHub Desktop.
rbenv install chef recipe
RBENV_DIR = "/usr/local/rbenv"
RUBY_VER = "1.9.3-p448"
# install packages
%w{
gcc
gcc-c++
openssl-devel
readline
readline-devel
zlib
zlib-devel
}.each do |package_name|
package package_name do
action :install
end
end
# install packages from epel
%w{
libyaml-devel
}.each do |package_name|
package package_name do
options "--enablerepo=epel"
action :install
end
end
git RBENV_DIR do
repository "git://github.com/sstephenson/rbenv.git"
reference "master"
action :sync
end
%w{shims versions plugins}.each do |dir|
directory "#{RBENV_DIR}/#{dir}" do
action :create
end
end
git "#{RBENV_DIR}/plugins/ruby-build" do
repository "git://github.com/sstephenson/ruby-build.git"
reference "master"
action :sync
end
bash "install_ruby_build" do
cwd "#{RBENV_DIR}/plugins/ruby-build"
code <<-EOH
./install.sh
EOH
end
template "/etc/profile.d/rbenv.sh" do
source "etc/profile.d/rbenv.sh.erb"
owner "root"
group "root"
mode "0644"
variables(
:rbenv_dir => RBENV_DIR
)
end
log "Installing #{RUBY_VER} ..."
bash "rbenv install #{RUBY_VER}" do
code <<-EOH
. /etc/profile.d/rbenv.sh
rbenv install #{RUBY_VER}
EOH
not_if { ::File.exists?("#{RBENV_DIR}/versions/#{RUBY_VER}") }
end
bash "rbenv global #{RUBY_VER}" do
code <<-EOH
. /etc/profile.d/rbenv.sh
rbenv global #{RUBY_VER}
EOH
end
bash "rbenv rehash" do
code <<-EOH
. /etc/profile.d/rbenv.sh
rbenv rehash
EOH
end
bash "install gems" do
{
"thor" => "0.18.1"
}.each_pair do |gem_name, version|
code <<-EOH
. /etc/profile.d/rbenv.sh
gem install #{gem_name} -v #{version}
EOH
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment