8

我正在尝试通过 Ubuntu 12.04 服务器上的操作码说明书安装 nginx。我知道这取决于 ohai,所以我也下载了那本食谱。当我跑

$ sudo chef-solo -c solo.rb

我收到一条错误消息

FATAL: Errno::ENOENT: No such file or directory - solo.rb

不确定当它在我当前目录中时,solo.rb 是如何丢失的。

$ ls
cache  cookbooks  node.json  node.json~  solo.rb  solo.rb~

这是调试的输出

$ sudo chef-solo -l debug -c solo.rb
[Sun, 20 May 2012 14:00:10 -0400] INFO: *** Chef 0.10.10 ***
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Building node object for vagrant-ubuntu-precise
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Extracting run list from JSON attributes provided on command line
[Sun, 20 May 2012 14:00:10 -0400] INFO: Setting the run_list to ["recipe[ohai]", "recipe[main]", "recipe[nginx]"] from JSON
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Applying attributes from json file
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Platform is ubuntu version 12.04
[Sun, 20 May 2012 14:00:10 -0400] INFO: Run List is [recipe[ohai], recipe[main], recipe[nginx]]
[Sun, 20 May 2012 14:00:10 -0400] INFO: Run List expands to [ohai, main, nginx]
[Sun, 20 May 2012 14:00:10 -0400] INFO: Starting Chef Run for vagrant-ubuntu-precise
[Sun, 20 May 2012 14:00:10 -0400] INFO: Running start handlers
[Sun, 20 May 2012 14:00:10 -0400] INFO: Start handlers complete.
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: No chefignore file found at /var/chef/cookbooks/chefignore no files will be ignored
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loading cookbook chef-jenkins's library file: /var/chef/cookbooks/chef-jenkins/libraries/manage_node.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loading cookbook chef-jenkins's providers from /var/chef/cookbooks/chef-jenkins/providers/job.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loaded contents of /var/chef/cookbooks/chef-jenkins/providers/job.rb into a provider named chef-jenkins_job defined in Chef::Provider::ChefJenkinsJob
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loading cookbook chef-jenkins's providers from /var/chef/cookbooks/chef-jenkins/providers/execute.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loaded contents of /var/chef/cookbooks/chef-jenkins/providers/execute.rb into a provider named chef-jenkins_execute defined in Chef::Provider::ChefJenkinsExecute
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loading cookbook chef-jenkins's providers from /var/chef/cookbooks/chef-jenkins/providers/node.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loaded contents of /var/chef/cookbooks/chef-jenkins/providers/node.rb into a provider named chef-jenkins_node defined in Chef::Provider::ChefJenkinsNode
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loading cookbook chef-jenkins's providers from /var/chef/cookbooks/chef-jenkins/providers/cli.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loaded contents of /var/chef/cookbooks/chef-jenkins/providers/cli.rb into a provider named chef-jenkins_cli defined in Chef::Provider::ChefJenkinsCli
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loading cookbook chef-jenkins's resources from /var/chef/cookbooks/chef-jenkins/resources/job.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loaded contents of /var/chef/cookbooks/chef-jenkins/resources/job.rb into a resource named chef-jenkins_job defined in Chef::Resource::ChefJenkinsJob
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loading cookbook chef-jenkins's resources from /var/chef/cookbooks/chef-jenkins/resources/node.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loaded contents of /var/chef/cookbooks/chef-jenkins/resources/node.rb into a resource named chef-jenkins_node defined in Chef::Resource::ChefJenkinsNode
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loading cookbook chef-jenkins's resources from /var/chef/cookbooks/chef-jenkins/resources/execute.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loaded contents of /var/chef/cookbooks/chef-jenkins/resources/execute.rb into a resource named chef-jenkins_execute defined in Chef::Resource::ChefJenkinsExecute
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loading cookbook chef-jenkins's resources from /var/chef/cookbooks/chef-jenkins/resources/cli.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loaded contents of /var/chef/cookbooks/chef-jenkins/resources/cli.rb into a resource named chef-jenkins_cli defined in Chef::Resource::ChefJenkinsCli
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Node vagrant-ubuntu-precise loading cookbook nginx's attribute file /var/chef/cookbooks/nginx/attributes/default.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Node vagrant-ubuntu-precise loading cookbook nginx's attribute file /var/chef/cookbooks/nginx/attributes/geoip.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Node vagrant-ubuntu-precise loading cookbook nginx's attribute file /var/chef/cookbooks/nginx/attributes/source.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Node vagrant-ubuntu-precise loading cookbook nginx's attribute file /var/chef/cookbooks/nginx/attributes/upload_progress.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Node vagrant-ubuntu-precise loading cookbook ohai's attribute file /var/chef/cookbooks/ohai/attributes/default.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Node vagrant-ubuntu-precise loading cookbook chef-jenkins's attribute file /var/chef/cookbooks/chef-jenkins/attributes/default.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loading cookbook nginx's definitions from /var/chef/cookbooks/nginx/definitions/nginx_site.rb
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Loading Recipe ohai via include_recipe
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Found recipe default in cookbook ohai
[Sun, 20 May 2012 14:00:10 -0400] INFO: ohai plugins will be at: /etc/chef/ohai_plugins
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Platform ubuntu not found, using all defaults. (Unsupported platform?)
[Sun, 20 May 2012 14:00:10 -0400] INFO: Processing remote_directory[/etc/chef/ohai_plugins] action create (ohai::default line 23)
[Sun, 20 May 2012 14:00:10 -0400] INFO: Processing cookbook_file[/etc/chef/ohai_plugins/README] action create (dynamically defined)
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Platform ubuntu not found, using all defaults. (Unsupported platform?)
[Sun, 20 May 2012 14:00:10 -0400] ERROR: Running exception handlers
[Sun, 20 May 2012 14:00:10 -0400] ERROR: Exception handlers complete
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Re-raising exception: Errno::ENOENT - No such file or directory - solo.rb
/var/chef/cookbooks/ohai/recipes/default.rb:41:in `read'
/var/chef/cookbooks/ohai/recipes/default.rb:41:in `from_file'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/cookbook_version.rb:578:in `load_recipe'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:46:in `load_recipe'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:33:in `include_recipe'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `each'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:72:in `load'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:69:in `each'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:69:in `load'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:199:in `setup_run_context'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:162:in `run'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:207:in `run_application'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in `loop'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in `run_application'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application.rb:70:in `run'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/chef-solo:25
/usr/local/bin/chef-solo:19:in `load'
/usr/local/bin/chef-solo:19
[Sun, 20 May 2012 14:00:10 -0400] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[Sun, 20 May 2012 14:00:10 -0400] DEBUG: Errno::ENOENT: No such file or directory - solo.rb
/var/chef/cookbooks/ohai/recipes/default.rb:41:in `read'
/var/chef/cookbooks/ohai/recipes/default.rb:41:in `from_file'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/cookbook_version.rb:578:in `load_recipe'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:46:in `load_recipe'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:33:in `include_recipe'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `each'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/mixin/language_include_recipe.rb:27:in `include_recipe'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:72:in `load'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:69:in `each'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/run_context.rb:69:in `load'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:199:in `setup_run_context'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/client.rb:162:in `run'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:207:in `run_application'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in `loop'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application/solo.rb:195:in `run_application'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/../lib/chef/application.rb:70:in `run'
/var/lib/gems/1.8/gems/chef-0.10.10/bin/chef-solo:25
/usr/local/bin/chef-solo:19:in `load'
/usr/local/bin/chef-solo:19
[Sun, 20 May 2012 14:00:10 -0400] FATAL: Errno::ENOENT: No such file or directory - solo.rb
4

4 回答 4

15

这是由于厨师的工作方式。它将目录更改为 / 以避免任何类型的权限问题,但这意味着需要访问命令行参数的插件将不再知道如何访问您的相对路径。

厨师代码中存在一个错误以解决该问题。

目前,为参数使用完整路径可以chef-solo解决问题。例如

$ chef-solo -c /full/path/to/solo.rb -j /full/path/to/node.json -l debug

或者正如其他人指出的那样,删除/etc/chef/ohai_plugins/README文件也将“解决”问题。虽然不是真正的方式,但因为所做的只是触发 ohai_plugins 文件夹上的修改时间更新,从而触发厨师重新加载所有内容。该功能无法保证,并且可能会在上述错误修复之前中断。

于 2012-07-25T14:19:12.443 回答
3

这似乎是 chef-solo 和 chef-client 的错误,我做了一些挖掘并在这里打开了一个错误:http: //tickets.opscode.com/browse/COOK-1490?focusedCommentId=25572#comment -25572

就像已经建议的那样,解决方法是使用配置的绝对路径,任何相对路径都有同样的问题。每当 ohai 配方在不更改任何插件的情况下运行时也会发生这种情况,它并不特定于 nginx 食谱。

于 2012-07-25T18:13:11.253 回答
2

问题很可能是每次运行都会重新创建的“/etc/chef/ohai_plugins/README”。你只需要在运行 chef-solo 之前删除它。

于 2012-07-01T07:35:16.450 回答
0

如果 chef-solo 0.10.10 找不到你的solo.rb,它会在你的调试日志开始时抱怨以下消息:

$ chef-solo -c solo.rb -l debug
[2012-06-18T23:27:32+03:00] WARN: *****************************************
[2012-06-18T23:27:32+03:00] WARN: Did not find config file: solo.rb, using command line options.
[2012-06-18T23:27:32+03:00] WARN: *****************************************
[2012-06-18T23:27:32+03:00] INFO: *** Chef 0.10.10 ***
...

所以错误在于以某种方式使用此配置文件名的配方的逻辑。

于 2012-06-18T20:29:52.160 回答