我遵循以下厨师教程:
http://gettingstartedwithchef.com/first-steps-with-chef.html
一切都在完美地运作,直到"属性"部分。创建节点[' phpapp'] ['数据库']条目并运行chef-solo之后,我得到以下内容。有任何想法吗?我一般都不熟悉红宝石,所以我很难自己调试它。
root@chef-solo:~/chef-repo# chef-solo -c solo.rb -j web.json
Starting Chef Client, version 11.8.2
Compiling Cookbooks...
/root/chef-repo/cookbooks/homebrew/libraries/homebrew_package.rb:26: warning: toplevel constant Homebrew referenced by Chef::Provider::Package::Homebrew
[2015-03-15T19:08:58+00:00] WARN: Cloning resource attributes for directory[/var/cache/local/preseeding] from prior resource (CHEF-3694)
[2015-03-15T19:08:58+00:00] WARN: Previous directory[/var/cache/local/preseeding]: /root/chef-repo/cookbooks/apt/recipes/default.rb:91:in `block in from_file'
[2015-03-15T19:08:58+00:00] WARN: Current directory[/var/cache/local/preseeding]: /root/chef-repo/cookbooks/mysql/recipes/_server_debian.rb:4:in `from_file'
[2015-03-15T19:08:58+00:00] WARN: Cloning resource attributes for directory[/var/lib/mysql] from prior resource (CHEF-3694)
[2015-03-15T19:08:58+00:00] WARN: Previous directory[/var/lib/mysql]: /root/chef-repo/cookbooks/mysql/recipes/_server_debian.rb:34:in `block in from_file'
[2015-03-15T19:08:58+00:00] WARN: Current directory[/var/lib/mysql]: /root/chef-repo/cookbooks/mysql/recipes/_server_debian.rb:78:in `from_file'
[2015-03-15T19:08:58+00:00] WARN: apache2::mod_php5 generally is expected to be run under a non-threaded MPM, such as prefork
[2015-03-15T19:08:58+00:00] WARN: See http://php.net/manual/en/faq.installation.php#faq.installation.apache2
[2015-03-15T19:08:58+00:00] WARN: Currently the apache2 cookbook is configured to use the 'event' MPM
[2015-03-15T19:08:58+00:00] WARN: node['build_essential'] has been changed to node['build-essential'] to match the
cookbook name and community standards. I have gracefully converted the attribute
for you, but this warning and conversion will be removed in the next major
release of the build-essential cookbook.
[2015-03-15T19:08:58+00:00] WARN: node['build-essential']['compiletime'] has been deprecated. Please use
node['build-essential']['compile_time'] instead. I have gracefully converted the
attribute for you, but this warning and converstion will be removed in the next
major release of the build-essential cookbook.
Recipe: build-essential::_debian
* package[autoconf] action install (up to date)
* package[binutils-doc] action install (up to date)
* package[bison] action install (up to date)
* package[build-essential] action install (up to date)
* package[flex] action install (up to date)
* package[gettext] action install (up to date)
* package[ncurses-dev] action install (up to date)
Recipe: mysql::client
* package[mysql-client] action install (up to date)
* package[libmysqlclient-dev] action install (up to date)
Recipe: mysql::ruby
* chef_gem[mysql] action install
================================================================================
Error executing action `install` on resource 'chef_gem[mysql]'
================================================================================
Gem::Installer::ExtensionBuildError
-----------------------------------
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:5:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/mysql-2.9.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/mysql-2.9.1/ext/mysql_api/gem_make.out
Cookbook Trace:
---------------
/root/chef-repo/cookbooks/mysql/recipes/ruby.rb:47:in `from_file'
/root/chef-repo/cookbooks/phpapp/recipes/default.rb:16:in `from_file'
Resource Declaration:
---------------------
# In /root/chef-repo/cookbooks/mysql/recipes/ruby.rb
47: chef_gem 'mysql'
Compiled Resource:
------------------
# Declared in /root/chef-repo/cookbooks/mysql/recipes/ruby.rb:47:in `from_file'
chef_gem("mysql") do
provider Chef::Provider::Package::Rubygems
action :install
retries 0
retry_delay 2
package_name "mysql"
version "2.9.1"
cookbook_name :mysql
recipe_name "ruby"
end
================================================================================
Recipe Compile Error in /root/chef-repo/cookbooks/phpapp/recipes/default.rb
================================================================================
Gem::Installer::ExtensionBuildError
-----------------------------------
chef_gem[mysql] (mysql::ruby line 47) had an error: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:5:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/mysql-2.9.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/mysql-2.9.1/ext/mysql_api/gem_make.out
Cookbook Trace:
---------------
/root/chef-repo/cookbooks/mysql/recipes/ruby.rb:47:in `from_file'
/root/chef-repo/cookbooks/phpapp/recipes/default.rb:16:in `from_file'
Relevant File Content:
----------------------
/root/chef-repo/cookbooks/mysql/recipes/ruby.rb:
40: end
41: end
42:
43: node['mysql']['client']['packages'].each do |name|
44: resources("package[#{name}]").run_action(:install)
45: end
46:
47>> chef_gem 'mysql'
48:
[2015-03-15T19:09:00+00:00] ERROR: Running exception handlers
[2015-03-15T19:09:00+00:00] ERROR: Exception handlers complete
[2015-03-15T19:09:00+00:00] FATAL: Stacktrace dumped to /root/chef-solo/chef-stacktrace.out
Chef Client failed. 0 resources updated
[2015-03-15T19:09:00+00:00] ERROR: chef_gem[mysql] (mysql::ruby line 47) had an error: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:5:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/mysql-2.9.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/mysql-2.9.1/ext/mysql_api/gem_make.out
[2015-03-15T19:09:00+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
root@chef-solo:~/chef-repo#
答案 0 :(得分:0)
似乎你错过了为ruby构建mysql gem所需的一些预期的ruby-dev工具。 chef_gem
通常会将宝石安装到随厨师自带的嵌入式Ruby版本中。鉴于您的输出引用了/var/lib/gems/1.9.1
和/usr/bin/ruby1.9.1
,我猜测您正在调用系统ruby,而不是主厨嵌入的系统(通常在/opt/chef/embedded/ruby
。
我建议您清理shell环境并重新安装厨师。您也可以通过调用chef ruby的gem命令并以这种方式安装mysql gem来手动尝试解决这个问题(/opt/chef/embedded/bin/gem install mysql
- 不确定该路径,但是您正在寻找gem
二进制文件在/opt/chef
)下。
答案 1 :(得分:0)
好吧,我最后“嘲笑”了一点。
apt-get install ruby-all-dev
这解决了ruby gem问题。然后我有一个错误,它抱怨与mysql2有关,所以:
gem install mysql2
我的厨师现在跑完了。谢谢大家的帮助。