使用'database :: mysql'配方安装mysql的Chef错误

时间:2014-01-16 16:10:42

标签: rubygems chef cookbook

来自Getting Started Writing Chef Cookbooks the Berkshelf Waymisheska blog教程。但特别是在Part 2 Mysql and Create database

执行时

$ vagrant up

$ vagrant provision

我在控制台输出中收到以下错误:

Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'opscode-ubuntu-12.04'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[Berkshelf] This version of the Berkshelf plugin has not been fully tested on this version of Vagrant.
[Berkshelf] You should check for a newer version of vagrant-berkshelf.
[Berkshelf] If you encounter any errors with this version, please report them at https://github.com/RiotGames/vagrant-berkshelf/issues
[Berkshelf] You can also join the discussion in #berkshelf on Freenode.
[Berkshelf] Updating Vagrant's berkshelf: '/home/montells/.berkshelf/default/vagrant/berkshelf-20140117-2071-x216zp-default'
[Berkshelf] Using myface (0.1.0)
[Berkshelf] Using mysql (4.0.18)
[Berkshelf] Using openssl (1.1.0)
[Berkshelf] Using build-essential (1.4.2)
[Berkshelf] Using apache2 (1.8.14)
[Berkshelf] Using database (1.6.0)
[Berkshelf] Using postgresql (3.3.4)
[Berkshelf] Using apt (2.3.4)
[Berkshelf] Using aws (1.0.0)
[Berkshelf] Using xfs (1.1.0)
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Setting hostname...
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant
[default] -- /tmp/vagrant-chef-1/chef-solo-1/cookbooks
[default] Running provisioner: chef_solo...
Generating chef JSON and uploading...
Running chef-solo...
stdin: is not a tty
[2014-01-17T14:42:52+00:00] INFO: Forking chef instance to converge...
[2014-01-17T14:42:52+00:00] INFO: *** Chef 11.8.2 ***
[2014-01-17T14:42:52+00:00] INFO: Chef-client pid: 1327
[2014-01-17T14:42:55+00:00] INFO: Setting the run_list to ["recipe[myface::default]"] from JSON
[2014-01-17T14:42:55+00:00] INFO: Run List is [recipe[myface::default]]
[2014-01-17T14:42:55+00:00] INFO: Run List expands to [myface::default]
[2014-01-17T14:42:55+00:00] INFO: Starting Chef Run for ubuntu
[2014-01-17T14:42:55+00:00] INFO: Running start handlers
[2014-01-17T14:42:55+00:00] INFO: Start handlers complete.
[2014-01-17T14:42:56+00:00] WARN: Cloning resource attributes for directory[/var/lib/mysql] from prior resource (CHEF-3694)
[2014-01-17T14:42:56+00:00] WARN: Previous directory[/var/lib/mysql]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/_server_debian.rb:34:in `block in from_file'
[2014-01-17T14:42:56+00:00] WARN: Current  directory[/var/lib/mysql]: /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/_server_debian.rb:70:in `from_file'
[2014-01-17T14:43:06+00:00] INFO: execute[apt-get-update-build-essentials] ran successfully
[2014-01-17T14:45:33+00:00] WARN:  failed to find gem mysql (>= 0) from [http://rubygems.org/]
[2014-01-17T14:45:33+00:00] ERROR: Running exception handlers
[2014-01-17T14:45:33+00:00] ERROR: Exception handlers complete
[2014-01-17T14:45:33+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-01-17T14:45:33+00:00] ERROR: chef_gem[mysql] (mysql::ruby line 47) had an error: ArgumentError: Illformed requirement [""]

================================================================================
Error executing action `install` on resource 'chef_gem[mysql]'
================================================================================


ArgumentError
-------------
Illformed requirement [""]


Cookbook Trace:
---------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/ruby.rb:47: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/myface/recipes/database.rb:11:in `from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/myface/recipes/default.rb:10:in `from_file'


Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/ruby.rb

 47: chef_gem 'mysql'



Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/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"
  cookbook_name :mysql
  recipe_name "ruby"
end




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


ArgumentError
-------------
chef_gem[mysql] (mysql::ruby line 47) had an error: ArgumentError: Illformed requirement [""]


Cookbook Trace:
---------------
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/mysql/recipes/ruby.rb:47: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/myface/recipes/database.rb:11:in `from_file'
  /tmp/vagrant-chef-1/chef-solo-1/cookbooks/myface/recipes/default.rb:10:in `from_file'


Relevant File Content:
----------------------
/tmp/vagrant-chef-1/chef-solo-1/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:  


[2014-01-17T14:42:52+00:00] INFO: Forking chef instance to converge...
[2014-01-17T14:45:33+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.

这是我的 myface / attributes / default.rb

default['myface']['user'] = 'myface'
default['myface']['group'] = 'myface'
default['myface']['name'] = 'myface'
default['myface']['config'] = 'myface.conf'
default['myface']['document_root'] = '/srv/apache/myface'

#**************** Database attr *********************************************
default['myface']['database']['host'] = 'localhost'
default['myface']['database']['username'] = 'root'
default['myface']['database']['password'] = node['mysql']['server_root_password']
default['myface']['database']['dbname'] = 'myface'

myface /食谱/ database.rb

include_recipe 'mysql::server'
include_recipe 'database::mysql'

mysql_database node['myface']['database']['dbname'] do
  connection(
    :host => node['myface']['database']['host'],
    :username => node['myface']['database']['username'],
    :password => node['myface']['database']['password']
  )
  action :create
end

myface /食谱/ default.rb

include_recipe 'myface::database'
include_recipe 'myface::webserver'

有人知道会发生什么? 注意:第1部分Install Apache2正常工作。 有趣的细节:我使用自己的本地gem服务器 geminabox 如果有人有想法,我可以提供更多细节。

1 个答案:

答案 0 :(得分:1)

读取调试输出,您的gem服务器不包含MySQL gem。