2012-07-10 91 views
5

我有一个VM与流浪汉和厨师。昨晚我的电脑在VM启动并运行时意外重新启动。之后,当我尝试将VM虚度时,我得到: 厨师从未成功完成!任何错误应该在上面的输出中可见。请修复您的食谱,以便它们正确完成。vagrant up问题

[default] VM already created. Booting if it's not already running... 
[default] Clearing any previously set forwarded ports... 
[default] Forwarding ports... 
[default] -- 22 => 2222 (adapter 1) 
[default] Creating shared folders metadata... 
[default] Clearing any previously set network interfaces... 
[default] Preparing network interfaces based on configuration... 
[default] Running any VM customizations... 
[default] Booting VM... 
[default] Waiting for VM to boot. This can take a few minutes. 
[default] VM booted and ready for use! 
[default] Configuring and enabling network interfaces... 
[default] Mounting shared folders... 
[default] -- v-root: /vagrant 
[default] -- v-data: /vagrant 
[default] -- v-csr-2: /tmp/vagrant-chef-1/chef-solo-2/roles 
[default] -- v-csc-1: /tmp/vagrant-chef-1/chef-solo-1/cookbooks 
[default] Running provisioner: Vagrant::Provisioners::ChefSolo... 
[default] Generating chef JSON and uploading... 
[default] Running chef-solo... 
stdin: is not a tty 
[Tue, 10 Jul 2012 00:59:36 -0700] INFO: *** Chef 0.10.2 *** 
[Tue, 10 Jul 2012 00:59:36 -0700] INFO: Setting the run_list to ["role[my-site]"] from JSON 
[Tue, 10 Jul 2012 00:59:36 -0700] INFO: Run List is [role[my-site]] 
[Tue, 10 Jul 2012 00:59:36 -0700] INFO: Run List expands to [memcached, my-site, my-site::vm] 
[Tue, 10 Jul 2012 00:59:36 -0700] INFO: Starting Chef Run for lucid32 
[Tue, 10 Jul 2012 00:59:37 -0700] ERROR: Running exception handlers 
[Tue, 10 Jul 2012 00:59:37 -0700] ERROR: Exception handlers complete 
[Tue, 10 Jul 2012 00:59:37 -0700] FATAL: Stacktrace dumped to /tmp/vagrant-chef-1/chef-stacktrace.out 
[Tue, 10 Jul 2012 00:59:37 -0700] FATAL: NoMethodError: undefined method `[]' for nil:NilClass 
Chef never successfully completed! Any errors should be visible in the 
output above. Please fix your recipes so that they properly complete. 

后来编辑:

堆栈跟踪转储到/tmp/vagrant-chef-1/chef-stacktrace.out

Generated at Tue Jul 10 00:59:37 -0700 2012 
NoMethodError: undefined method `[]' for nil:NilClass 
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/my-site/recipes/default.rb:114:in `from_file' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:69:in `instance_eval' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/recipe_definition_dsl_core.rb:69:in `method_missing' 
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/my-site/recipes/default.rb:109:in `from_file' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/cookbook_version.rb:578:in `load_recipe' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/language_include_recipe.rb:40:in `include_recipe' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `each' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/run_context.rb:72:in `load' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/run_context.rb:69:in `each' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/run_context.rb:69:in `load' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/client.rb:195:in `setup_run_context' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/client.rb:159:in `run' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/application/solo.rb:192:in `run_application' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/application/solo.rb:183:in `loop' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/application/solo.rb:183:in `run_application' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/../lib/chef/application.rb:66:in `run' 
/opt/ruby/lib/ruby/gems/1.8/gems/chef-0.10.2/bin/chef-solo:25 
/opt/ruby/bin/chef-solo:19:in `load' 
/opt/ruby/bin/chef-solo:19 

任何想法,

谢谢, Radu

+0

'/ tmp/vagrant-chef-1/chef-stacktrace.out'中的堆栈跟踪是什么样的? – 2012-07-10 08:10:00

+0

将其添加为稍后的编辑 – Radu 2012-07-10 08:21:29

+0

以前厨师是否运行完成,没有错误? 在'my-site/recipes/default.rb'的第114行中,您可能正在访问某个不存在的节点属性。看看这行代码,你是否认识到哪里的对象是零,你能否做到这一点,所以它不是零? – 2012-07-10 08:51:25

回答

6

这是你厨师食谱本身的错误。如果您阅读堆栈跟踪,您可以看到错误实际上位于my-site食谱的默认配方的第114行。您看到的Ruby错误意味着您正在尝试执行诸如a[:foo]之类的操作,其中anil。当然,您不能致电[]nil

2

我有同样的问题。我发现虚拟机中运行的主机版本太旧了(0.10.10)。

你必须更新:

 
local$ vagrant ssh 
vagrant$ gem install chef 

,然后再试一次。

+1

作为根/ sudo运行。作为用户vagrant你会得到这个错误:“你没有写入/opt/vagrant_ruby/lib/ruby/gems/1.8目录的权限” – Henk 2013-03-17 08:10:04

0

我收到的错误:

Chef never successfully completed! Any errors should be visible in the 
output above. Please fix your recipes so that they properly complete. 

Error executing action `create` on resource 'mysql_service[default]' 

我用:

local$ vagrant ssh 
vagrant$ gem install chef 

再次尝试后,这一切都制定了完善。