Chef経由でCentOS6.5にredmine入れようとした時にopscodeのbuild-essential cookbookで
yumリポジトリに「kernel-devel」がないおエラーが発生してハマったので、その対処法覚書
結論
/etc/yum.conf
にexclude=kernel*
が書かれてたのでそれを消す or コメントアウト
環境
- Chef 11.8.2
- CentOS 6.5(vagrantのbox CentOS 6.5 x86_64)
- build-essential 1.4.2
対処前に出たエラー
================================================================================
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.conf
のexclude=kernel*
をコメントアウトするだけ
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.
細かいところは間違っているかもなのでお気をつけて