LoginSignup
3
2

More than 5 years have passed since last update.

chefでrbenv・ruby環境作り

Posted at

chefでrbenv・rubyの環境を作るためのレシピを作ったのでメモ。
レシピを実行するとruby-2.2.2がインストールされる。

# rbenvインストール
git '/usr/local/rbenv' do
  repository 'https://github.com/sstephenson/rbenv.git'
  reference 'master'
  user 'root'
  group 'root'
  action :checkout
end

directory "/usr/local/rbenv/shims" do
  owner 'root'
  group 'root'
  mode 00755
  action :create
end

directory "/usr/local/rbenv/versions" do
  owner 'root'
  group 'root'
  mode 00755
  action :create
end

directory "/usr/local/rbenv/plugins" do
  owner 'root'
  group 'root'
  mode 00755
  action :create
end

cookbook_file "/etc/profile.d/rbenv.sh" do
  source 'rbenv.sh'
  owner 'root'
  group 'root'
  mode 0644
end

# ruby-buildインストール
git '/usr/local/rbenv/plugins/ruby-build' do
  repository 'https://github.com/sstephenson/ruby-build.git'
  reference 'master'
  user 'root'
  group 'root'
  action :checkout
end

# ruby install
execute 'rbnev-install' do
  not_if 'source /etc/profile.d/rbenv.sh; rbenv versions | grep 2.2.2'
  command 'source /etc/profile.d/rbenv.sh; rbenv install 2.2.2'
end

# rubyバージョン設定
execute 'rbnev-global' do
  not_if 'source /etc/profile.d/rbenv.sh; rbenv global | grep 2.2.2'
  command 'source /etc/profile.d/rbenv.sh; rbenv global 2.2.2; rbenv rehash'
end
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2