1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OpsWorks chef_gemエラーが発生したので応急処置でバージョン指定

Last updated at Posted at 2017-02-21
[2017-02-21T13:04:15+00:00] INFO: Installing chef-gem fog = 1.37.0
ERROR:  Error installing fog:
nokogiri requires Ruby version >= 2.1.0.

nokogiriが入らなくてエラーだったぽい。

うまく動いているインスタンスのgemバージョンをみる

$ ls /opt/aws/opsworks/releases/20161019094202_3441-20161019094202/vendor/bundle/ruby/2.0.0/gems

nokogiri-1.6.8.1

OpsWorks ChefのRubyバージョンは

$ /opt/aws/opsworks/local/bin/ruby -v
ruby 2.0.0p645 (2015-04-13 revision 50299) [x86_64-linux]

nokogiriのrubygemsページで見ると、1.7からRuby 2.1が必要で、このせいで落ちたみたい。

レシピで指定する

カスタムcookbooksに書いておこう…

# opsworks/attribtes/default.rb
defalt[:nokogiri_version] = '1.6.8.1'
chef_gem "nokogiri" do
  action :install
  version node[:nokogiri_version]
end

Update Custom Cookbooksして試しに動かしてみる。

$ sudo opsworks-agent-cli run_command update_custom_cookbooks
$ sudo opsworks-agent-cli run_command configure

configureの部分は実行したいコマンド。

recipeのメンテが辛くなる…よくない

中途半端にインストールされたgemで依存関係が壊れたとき

# sudo su -
# cd /opt/aws/opsworks/releases/20161019094202_3441-20161019094202
# rm -rf vendor/bundler
# /opt/aws/opsworks/local/bin/bundle install

ただ、そこまでくると諦めてインスタンス作り直した方がいいかも。

1
1
1

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?