Last active
October 25, 2015 12:45
-
-
Save kenji0x02/8771458 to your computer and use it in GitHub Desktop.
rvmな人が流行にのっかってrbenv使って、ついでにChefったときにひかかったんで、 ref: http://qiita.com/kenji0x02/items/0f8d3f7563a13500d8be
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git "/usr/local/rbenv" do | |
repository "git://github.com/sstephenson/rbenv.git" | |
reference "master" | |
action :sync | |
end | |
# 各バージョンのrubyはversions/以下におかれる | |
# 使用中のrubyがshims/以下におかれる | |
%w{/usr/local/rbenv/shims /usr/local/rbenv/versions}.each do |dir| | |
directory dir do | |
action :create | |
end | |
end | |
# rbenv自体にはrubyのインストール機能は含まれないんだってさ | |
git "/usr/local/ruby-build" do | |
repository "git://github.com/sstephenson/ruby-build.git" | |
reference "master" | |
action :sync | |
end | |
bash "install_ruby_build" do | |
not_if 'which ruby-build' | |
cwd "/usr/local/ruby-build" | |
code <<-EOH | |
./install.sh | |
EOH | |
end | |
# 環境変数の設定 | |
template "rbenv.sh" do | |
path "/etc/profile.d/rbenv.sh" | |
owner "root" | |
group "root" | |
mode "0644" | |
source "rbenv.sh.erb" | |
end | |
# rubyのインストールに必要な物を入れる | |
# EPEL必須 | |
%w{make gcc zlib-devel openssl-devel readline-devel ncurses-devel gdbm-devel db4-devel libffi-devel tk-devel libyaml-devel}.each do |pkg| | |
yum_package pkg do | |
action :install | |
end | |
end | |
# rubyインストール(ビルドに数10分かかる、、、) | |
# 【注意】この段階では環境変数が適用されていないので | |
# rbenv.shを読み込むことで環境変数を適用 | |
bash "install ruby (This may take several tens of minutes...)" do | |
code <<-EOC | |
source /etc/profile.d/rbenv.sh | |
rbenv install #{node['ruby']['version']} | |
EOC | |
# ここにrubyの本体がいる | |
creates "/usr/local/rbenv/versions/#{node['ruby']['version']}" | |
end | |
bash "ruby change to #{node['ruby']['version']}" do | |
# 「設定されていたら何もしない」を不細工に表現w | |
not_if "source /etc/profile.d/rbenv.sh; rbenv versions | grep '* #{node.ruby.version}'" | |
code <<-EOC | |
source /etc/profile.d/rbenv.sh | |
rbenv global #{node['ruby']['version']} | |
rbenv rehash | |
EOC | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git "/usr/local/rbenv" do | |
repository "git://github.com/sstephenson/rbenv.git" | |
reference "master" | |
action :sync | |
end | |
# 各バージョンのrubyはversions/以下におかれる | |
# 使用中のrubyがshims/以下におかれる | |
%w{/usr/local/rbenv/shims /usr/local/rbenv/versions}.each do |dir| | |
directory dir do | |
action :create | |
end | |
end | |
# rbenv自体にはrubyのインストール機能は含まれないんだってさ | |
git "/usr/local/ruby-build" do | |
repository "git://github.com/sstephenson/ruby-build.git" | |
reference "master" | |
action :sync | |
end | |
bash "install_ruby_build" do | |
not_if 'which ruby-build' | |
cwd "/usr/local/ruby-build" | |
code <<-EOH | |
./install.sh | |
EOH | |
end | |
# 環境変数の設定 | |
template "rbenv.sh" do | |
path "/etc/profile.d/rbenv.sh" | |
owner "root" | |
group "root" | |
mode "0644" | |
source "rbenv.sh.erb" | |
end | |
# rubyのインストールに必要な物を入れる | |
# EPEL必須 | |
%w{make gcc zlib-devel openssl-devel readline-devel ncurses-devel gdbm-devel db4-devel libffi-devel tk-devel libyaml-devel}.each do |pkg| | |
yum_package pkg do | |
action :install | |
end | |
end | |
# rubyインストール(ビルドに数10分かかる、、、) | |
# 【注意】この段階では環境変数が適用されていないので | |
# rbenv.shを読み込むことで環境変数を適用 | |
bash "install ruby (This may take several tens of minutes...)" do | |
code <<-EOC | |
source /etc/profile.d/rbenv.sh | |
rbenv install #{node['ruby']['version']} | |
EOC | |
# ここにrubyの本体がいる | |
creates "/usr/local/rbenv/versions/#{node['ruby']['version']}" | |
end | |
bash "ruby change to #{node['ruby']['version']}" do | |
# 「設定されていたら何もしない」を不細工に表現w | |
not_if "source /etc/profile.d/rbenv.sh; rbenv versions | grep '* #{node.ruby.version}'" | |
code <<-EOC | |
source /etc/profile.d/rbenv.sh | |
rbenv global #{node['ruby']['version']} | |
rbenv rehash | |
EOC | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment