Vagrant “未定义的方法”;cheffish“;对于nil:NilClass,当为厨师提供流浪汉时

Vagrant “未定义的方法”;cheffish“;对于nil:NilClass,当为厨师提供流浪汉时,vagrant,chef-infra,Vagrant,Chef Infra,我正试图使用Chef在一个流浪者的盒子里运行django服务器,但我已经在这上面停留了几个小时,在网上找不到任何东西。我的Vagrant文件的相关部分如下:(很抱歉缩进不好)此外,该框正在运行centos7 config.vm.provision :chef_solo do |chef| chef.cookbooks_path = "cookbooks" chef.add_recipe "apache2" chef.add_recipe "apt" chef.add_recipe "bluepi

我正试图使用Chef在一个流浪者的盒子里运行django服务器,但我已经在这上面停留了几个小时,在网上找不到任何东西。我的Vagrant文件的相关部分如下:(很抱歉缩进不好)此外,该框正在运行centos7

config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "apache2"
chef.add_recipe "apt"
chef.add_recipe "bluepill"
chef.add_recipe "build-essential"
chef.add_recipe "chef-sugar"
chef.add_recipe "chef_handler"
chef.add_recipe "cms-scanner"
chef.add_recipe "gunicorn"
chef.add_recipe "homebrew"
chef.add_recipe "install_from"
chef.add_recipe "iptables"
chef.add_recipe "logrotate"
chef.add_recipe "metachef"
chef.add_recipe "mysql"
chef.add_recipe "nginx"
chef.add_recipe "ohai"
chef.add_recipe "openssl"
chef.add_recipe "packagecloud"
chef.add_recipe "pacman"
chef.add_recipe "python"
chef.add_recipe "rbac"
chef.add_recipe "redis"
chef.add_recipe "runit"
chef.add_recipe "smf"
chef.add_recipe "windows"
chef.add_recipe "yum"
chef.add_recipe "yum-epel"
end
当我运行
vagrant provision

 C:\Users\garrowa\Desktop\cms-vagrant>vagrant provision
    ==> default: Running provisioner: chef_solo...
    ==> default: Detected Chef (latest) is already installed
    Generating chef JSON and uploading...
    ==> default: Running chef-solo...
    ==> default: [2015-06-30T18:04:53-04:00] INFO: Forking chef instance to converge
    ...
    ==> default: [2015-06-30T18:04:53-04:00] INFO: *** Chef 12.4.0 ***
    ==> default: [2015-06-30T18:04:53-04:00] INFO: Chef-client pid: 4398
    ==> default: [2015-06-30T18:04:55-04:00] INFO: Setting the run_list to ["recipe[
    apache2]", "recipe[apt]", "recipe[bluepill]", "recipe[build-essential]", "recipe
    [chef-sugar]", "recipe[chef_handler]", "recipe[cms-scanner]", "recipe[gunicorn]"
    , "recipe[homebrew]", "recipe[install_from]", "recipe[iptables]", "recipe[logrot
    ate]", "recipe[metachef]", "recipe[mysql]", "recipe[nginx]", "recipe[ohai]", "re
    cipe[openssl]", "recipe[packagecloud]", "recipe[pacman]", "recipe[python]", "rec
    ipe[rbac]", "recipe[redis]", "recipe[runit]", "recipe[smf]", "recipe[windows]",
    "recipe[yum]", "recipe[yum-epel]"] from CLI options
    ==> default: [2015-06-30T18:04:55-04:00] INFO: Run List is [recipe[apache2], rec
    ipe[apt], recipe[bluepill], recipe[build-essential], recipe[chef-sugar], recipe[
    chef_handler], recipe[cms-scanner], recipe[gunicorn], recipe[homebrew], recipe[i
    nstall_from], recipe[iptables], recipe[logrotate], recipe[metachef], recipe[mysq
    l], recipe[nginx], recipe[ohai], recipe[openssl], recipe[packagecloud], recipe[p
    acman], recipe[python], recipe[rbac], recipe[redis], recipe[runit], recipe[smf],
     recipe[windows], recipe[yum], recipe[yum-epel]]
    ==> default: [2015-06-30T18:04:55-04:00] INFO: Run List expands to [apache2, apt
    , bluepill, build-essential, chef-sugar, chef_handler, cms-scanner, gunicorn, ho
    mebrew, install_from, iptables, logrotate, metachef, mysql, nginx, ohai, openssl
    , packagecloud, pacman, python, rbac, redis, runit, smf, windows, yum, yum-epel]

    ==> default: [2015-06-30T18:04:55-04:00] INFO: Starting Chef Run for localhost
    ==> default: [2015-06-30T18:04:55-04:00] INFO: Running start handlers
    ==> default: [2015-06-30T18:04:55-04:00] INFO: Start handlers complete.
    ==> default: [2015-06-30T18:04:55-04:00] ERROR: Running exception handlers
    ==> default: [2015-06-30T18:04:55-04:00] ERROR: Exception handlers complete
    ==> default: [2015-06-30T18:04:55-04:00] ERROR: undefined method `cheffish' for
    nil:NilClass
    ==> default: [2015-06-30T18:04:55-04:00] FATAL: Chef::Exceptions::ChildConvergeE
    rror: 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.
真正让我困惑的是,我在这些食谱中找不到任何提到切菲什的地方


我已尝试删除所有
chef.add_recipe
行,除了
ohai
,或者
yum
,但我仍然得到相同的错误。(在两次尝试之间,我正在运行
vagrant reload
vagrant provision
。我也尝试过进入盒子,移除
cheffish
gem,运行
vagrant provision
,然后重新安装
cheffish
gem并运行
vagrant provision
,但没有任何效果。

最终得到了它。正如所指出的那样在chef v.12.4.0中引入了这个问题的注释中,我将行
chef.version=“12.3.0”
添加到了provision块,现在它开始工作了。

当使用自定义烹饪书时,在该自定义烹饪书的配方顶部使用include_recipe调用时,我遇到了完全相同的错误。 对我来说,解决这个问题的方法是在自定义食谱中添加一个metadata.rb。它应该包含名称和相关部分。
希望这对你有所帮助,如果你尝试在metadata.rb中使用
包含属性'foo'
,而不是属性文件。

对我来说,解决方案是确保我使用的每本烹饪书都有一个“名字”属性中包含烹饪书的名称。“redis”、“install_from”和“metachef”烹饪书都缺少metadata.rb中的name字段


chef client v12.3.0帮助发现了这一点,12.4.1没有向我显示任何有用的内容

我的错误与两本自定义烹饪书有关,有人在元数据中使用了相同的名称。rb更正了它。

但是,我在测试厨房中也遇到了同样的错误,这不是由错误引起的。错误消息是异常的不满足烹饪书约束的一般情况(即找不到烹饪书名称或版本)在我的例子中,在.kitchen.yml中,我包含了一个具有特定cookbook版本约束的环境,然后在一个Berksfile中指定了冲突的版本约束。这是愚蠢的,所以不要这样做!

由于从cookbook的
metadata.rb
中省略了
名称而得到了这一点。添加
名称
修复了它


我们看到的信息显然是Chef中的一个错误,希望很快会得到修复,但与此同时,也许这可以帮助任何犯下与我相同错误的人。

Cheffish是,所以你是对的,它没有被你的烹饪书所吸引。我不知道你为什么会犯这样的错误。我今天作为well-我猜它是在12.4.0中引入的。我也不想说我,但我也是。@MattO你说得对,我切换到12.3.0,现在它工作了:)12.4.1中仍然是一个bug。另外,值得注意的是,如果将chef provisioner的日志级别设置为debug(chef.log_level=:debug),则可能会看到其他错误。那个乱七八糟的东西掩盖了真正的错误。嘿,谢谢你的回答,我不认为这和我的食谱有任何关系,即使我根本没有包括它,我也有同样的错误。不过,改变chef版本解决了这个问题。这是12.4.0中的一个bug,还是向后兼容性中断?Vagrant文件中的设置对我不起作用;我可以在Vagrant中设置.kitchen.yml:
provisioner:name:chef_solo require_chef_omnibus:12.3.0
的版本。对我来说,将
require_chef_omnibus:12.3.0
添加到
.kitchen.yml
会导致“烹饪书中缺少“name”属性”错误。在每个食谱中将“name”属性添加到
metadata.rb
之后,它就可以工作了。