22
22

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.

Chefでbuild-essential cookbookを使った時にkernel-develが存在しないエラーが発生するときの対処

Last updated at Posted at 2013-12-31

Chef経由でCentOS6.5にredmine入れようとした時にopscodeのbuild-essential cookbookで
yumリポジトリに「kernel-devel」がないおエラーが発生してハマったので、その対処法覚書

結論

/etc/yum.confexclude=kernel*が書かれてたのでそれを消す or コメントアウト

環境

対処前に出たエラー

chef.log
================================================================================
Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/redmine/recipes/default.rb
================================================================================


Chef::Exceptions::Package
-------------------------
package[kernel-devel] (build-essential::rhel line 38) had an error: Chef::Exceptions::Package: No version specified, and no candidate version available for kernel-devel


Cookbook Trace:
---------------
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/build-essential/recipes/rhel.rb:41:in `block in from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/build-essential/recipes/rhel.rb:36:in `each'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/build-essential/recipes/rhel.rb:36:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/build-essential/recipes/default.rb:21:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/ruby.rb:24:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/database/recipes/mysql.rb:20:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/redmine/recipes/source.rb:56:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/redmine/recipes/default.rb:23:in `from_file'


Relevant File Content:
----------------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/build-essential/recipes/rhel.rb:

 34:  end
 35:
 36:  pkgs.flatten.each do |pkg|
 37:
 38:    r = package pkg do
 39:      action( node['build_essential']['compiletime'] ? :nothing : :install )
 40:    end
 41>>   r.run_action(:install) if node['build_essential']['compiletime']
 42:
 43:  end
 44:


[2013-12-31T10:08:26+00:00] INFO: Forking chef instance to converge...
[2013-12-31T10:09:17+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

作ったrecipe

/ect/yum.confexclude=kernel*をコメントアウトするだけ

commentout_yumconfg_exclude_kernel.rb
file '/etc/yum.conf' do 
  _file = Chef::Util::FileEdit.new(path)
  _file.search_file_replace_line('exclude=kernel', "#exclude=kernel\n")
  content _file.send(:contents).join
  action :create
end.run_action(:create)

このレシピがbuild-essentialのレシピを呼び出すより先に動くようにしておく

run_actionしているのはbuild-essentialがinclude_recipeされて先に動くっぽかったので、それより前に来れを動かしたかったのでそうしました。

また最新版のyum cookbookではyum_globalconfig resourceがあるので、そっちでちゃんと設定したほうが良いかも。

その他

opscodeのmysql cookbookあたりとか他にも色んなcookbookでbuild-essentialがinclude_recipeされているっぽいので
なんか同じエラーがあったら試してみてください

p.s.

細かいところは間違っているかもなのでお気をつけて

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?