kikeda1104's blog

備忘録・技術に関することを書いています。(webエンジニア)

Chefのエラー( Error executing action `install` on resource 'package[kernel-devel]' )

こんばんは。ツールに慣れるの一苦労しているkikeda1104です。 掲題のエラーが発生して対応したので、メモしておきます。

Vagrant provision

エラーメッセージ長いですが、書いておくと。

[Kikeda@10/16 22:22:03] vagrant provision                                                [~/work/vagrant/site-cookbooks/rails_book_cookbook]
[default] Chef 11.16.4 Omnibus package is already installed.
[default] Running provisioner: chef_solo...
Generating chef JSON and uploading...
Running chef-solo...
[2014-10-16T13:22:26+00:00] INFO: Forking chef instance to converge...
[2014-10-16T13:22:26+00:00] WARN: 
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SSL validation of HTTPS requests is disabled. HTTPS connections are still
encrypted, but chef is not able to detect forged replies or man in the middle
attacks.

To fix this issue add an entry like this to your configuration file:

  # Verify all HTTPS connections (recommended)
  ssl_verify_mode :verify_peer

  # OR, Verify only connections to chef-server
  verify_api_cert true

To check your SSL configuration, or troubleshoot errors, you can use the
`knife ssl check` command like so:

  knife ssl check -c /tmp/vagrant-chef-1/solo.rb

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

[2014-10-16T13:22:26+00:00] INFO: *** Chef 11.16.4 ***
[2014-10-16T13:22:26+00:00] INFO: Chef-client pid: 2373
[2014-10-16T13:22:34+00:00] INFO: Setting the run_list to ["vagrant_book"] from CLI options
[2014-10-16T13:22:34+00:00] INFO: Run List is [recipe[vagrant_book]]
[2014-10-16T13:22:34+00:00] INFO: Run List expands to [vagrant_book]
[2014-10-16T13:22:34+00:00] INFO: Starting Chef Run for vagrant-centos65.vagrantup.com
[2014-10-16T13:22:34+00:00] INFO: Running start handlers
[2014-10-16T13:22:34+00:00] INFO: Start handlers complete.
[2014-10-16T13:23:21+00:00] INFO: execute[yum -y update] ran successfully
[2014-10-16T13:23:24+00:00] INFO: execute[rm -rf /var/www] ran successfully
[2014-10-16T13:23:24+00:00] INFO: link[/var/www] created
[2014-10-16T13:23:24+00:00] INFO: Chef Run complete in 50.705252344 seconds
[2014-10-16T13:23:24+00:00] INFO: Running report handlers
[2014-10-16T13:23:24+00:00] INFO: Report handlers complete
[default] Running provisioner: chef_solo...
Generating chef JSON and uploading...
Running chef-solo...
[2014-10-16T13:23:30+00:00] INFO: Forking chef instance to converge...
[2014-10-16T13:23:30+00:00] WARN: 
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
SSL validation of HTTPS requests is disabled. HTTPS connections are still
encrypted, but chef is not able to detect forged replies or man in the middle
attacks.

To fix this issue add an entry like this to your configuration file:

  # Verify all HTTPS connections (recommended)
  ssl_verify_mode :verify_peer

  # OR, Verify only connections to chef-server
  verify_api_cert true

To check your SSL configuration, or troubleshoot errors, you can use the
`knife ssl check` command like so:

  knife ssl check -c /tmp/vagrant-chef-2/solo.rb

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

[2014-10-16T13:23:30+00:00] INFO: *** Chef 11.16.4 ***
[2014-10-16T13:23:30+00:00] INFO: Chef-client pid: 2818
[2014-10-16T13:23:36+00:00] INFO: Setting the run_list to ["recipe[build-essential]", "recipe[git]", "recipe[memcached]", "recipe[nodejs]", "recipe[database]", "recipe[xml]", "recipe[ruby_build]", "recipe[rbenv::system]", "recipe[nginx]", "recipe[imagemagick]", "recipe[rails_book_cookbook::ops_user]", "recipe[rails_book_cookbook::keys]", "recipe[rails_book_cookbook::sqlite3_dev]", "recipe[rails_book_cookbook::nginx_setting]"] from CLI options
[2014-10-16T13:23:36+00:00] INFO: Run List is [recipe[build-essential], recipe[git], recipe[memcached], recipe[nodejs], recipe[database], recipe[xml], recipe[ruby_build], recipe[rbenv::system], recipe[nginx], recipe[imagemagick], recipe[rails_book_cookbook::ops_user], recipe[rails_book_cookbook::keys], recipe[rails_book_cookbook::sqlite3_dev], recipe[rails_book_cookbook::nginx_setting]]
[2014-10-16T13:23:36+00:00] INFO: Run List expands to [build-essential, git, memcached, nodejs, database, xml, ruby_build, rbenv::system, nginx, imagemagick, rails_book_cookbook::ops_user, rails_book_cookbook::keys, rails_book_cookbook::sqlite3_dev, rails_book_cookbook::nginx_setting]
[2014-10-16T13:23:36+00:00] INFO: Starting Chef Run for vagrant-centos65.vagrantup.com
[2014-10-16T13:23:36+00:00] INFO: Running start handlers
[2014-10-16T13:23:36+00:00] INFO: Start handlers complete.
[2014-10-16T13:23:39+00:00] INFO: WindowsPackage lightweight resource already initialized -- overriding!
[2014-10-16T13:23:39+00:00] WARN: Cloning resource attributes for package[git] from prior resource (CHEF-3694)
[2014-10-16T13:23:39+00:00] WARN: Previous package[git]: /tmp/vagrant-chef-2/chef-solo-1/cookbooks/git/recipes/default.rb:31:in `from_file'
[2014-10-16T13:23:39+00:00] WARN: Current  package[git]: /tmp/vagrant-chef-2/chef-solo-1/cookbooks/ruby_build/recipes/default.rb:38:in `block in from_file'
[2014-10-16T13:23:39+00:00] WARN: Cloning resource attributes for package[git] from prior resource (CHEF-3694)
[2014-10-16T13:23:39+00:00] WARN: Previous package[git]: /tmp/vagrant-chef-2/chef-solo-1/cookbooks/ruby_build/recipes/default.rb:38:in `block in from_file'
[2014-10-16T13:23:39+00:00] WARN: Current  package[git]: /tmp/vagrant-chef-2/chef-solo-1/cookbooks/rbenv/libraries/chef_rbenv_recipe_helpers.rb:43:in `block in install_rbenv_pkg_prereqs'
[2014-10-16T13:23:39+00:00] INFO: ohai plugins will be at: /etc/chef/ohai_plugins
[2014-10-16T13:23:46+00:00] INFO: ohai[custom_plugins] reloaded
[2014-10-16T13:23:46+00:00] WARN: Cloning resource attributes for service[nginx] from prior resource (CHEF-3694)
[2014-10-16T13:23:46+00:00] WARN: Previous service[nginx]: /tmp/vagrant-chef-2/chef-solo-1/cookbooks/nginx/recipes/package.rb:46:in `from_file'
[2014-10-16T13:23:46+00:00] WARN: Current  service[nginx]: /tmp/vagrant-chef-2/chef-solo-1/cookbooks/nginx/recipes/default.rb:24:in `from_file'
[2014-10-16T13:23:46+00:00] WARN: Cloning resource attributes for template[/etc/nginx/sites-available/default] from prior resource (CHEF-3694)
[2014-10-16T13:23:46+00:00] WARN: Previous template[/etc/nginx/sites-available/default]: /tmp/vagrant-chef-2/chef-solo-1/cookbooks/nginx/recipes/commons_conf.rb:31:in `from_file'
[2014-10-16T13:23:46+00:00] WARN: Current  template[/etc/nginx/sites-available/default]: /tmp/vagrant-chef-2/chef-solo-2/cookbooks/rails_book_cookbook/recipes/nginx_setting.rb:10:in `from_file'

================================================================================
Error executing action `install` on resource 'package[kernel-devel]'
================================================================================

Chef::Exceptions::Package
-------------------------
No version specified, and no candidate version available for kernel-devel

Resource Declaration:
---------------------
# In /tmp/vagrant-chef-2/chef-solo-1/cookbooks/build-essential/recipes/_rhel.rb

 26:   package 'kernel-devel'
 27:   package 'make'

Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-2/chef-solo-1/cookbooks/build-essential/recipes/_rhel.rb:26:in `block in from_file'

package("kernel-devel") do
  action :install
  retries 0
  retry_delay 2
  guard_interpreter :default
  package_name "kernel-devel"
  timeout 900
  cookbook_name :"build-essential"
  recipe_name "_rhel"
end

[2014-10-16T13:23:58+00:00] INFO: Running queued delayed notifications before re-raising exception
[2014-10-16T13:23:58+00:00] ERROR: Running exception handlers
[2014-10-16T13:23:58+00:00] ERROR: Exception handlers complete
[2014-10-16T13:23:58+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-10-16T13:23:59+00:00] ERROR: package[kernel-devel] (build-essential::_rhel line 26) had an error: Chef::Exceptions::Package: No version specified, and no candidate version available for kernel-devel
[2014-10-16T13:23:59+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.

対策

対応としては、/etc/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)

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

記事でも言われているが、今度、ちゃんとやろう・・w

この辺のエラーは、(´・ω・`)となるから、ちゃんと調べて理解したんだけど。 今回は、記事に乗っている対処に乗っ取って暫定的に対応で終了。

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