未定义的方法“cheffish”为nil:NilClass,供应厨师与流浪汉

时间:2015-06-30 22:25:01

标签: vagrant chef

我正在尝试使用Chef在Vagrant框中运行django-server,但我已经被困在这几个小时,在网上找不到任何东西。我的vagrantfile的相关位看起来像这样:(抱歉压痕很差)另外,这个盒子正在运行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.

让我感到困惑的是,在任何这些食谱中,我都找不到任何关于cheffish的提法。

我已尝试删除除chef.add_recipe以外的所有ohai行,或yum,但我仍然会收到相同的错误。 (我在尝试之间运行vagrant reloadvagrant provision。我也尝试将sshing放入框中,移除cheffish gem,运行vagrant provision,然后重新安装{{1宝石和正在运行cheffish,但无济于事。

6 个答案:

答案 0 :(得分:7)

终于明白了。正如评论中指出的那样,这个问题在大厨第12.4.0节中引入,我将行chef.version = "12.3.0"添加到供应块中,现在它正在运行。

答案 1 :(得分:1)

对我来说,解决方案是确保我使用的每本食谱都有一个名字"在其中使用cookbook的名称进行属性。 ' redis',' install_from',' metachef' cookbook都缺少metadata.rb的名称字段

chef-client v12.3.0帮助发现了这一点,12.4.1没有向我展示任何有用的东西

答案 2 :(得分:0)

在自定义食谱中使用自定义食谱和配方顶部的include_recipe调用时,我遇到了完全相同的错误。 为我修复的是将metadata.rb添加到自定义菜谱中。它应该包含名称和依赖部分。 希望这有帮助

答案 3 :(得分:0)

如果您尝试在metadata.rb而不是属性文件中使用include_attribute 'foo',则会发生这种情况。

答案 4 :(得分:0)

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

答案 5 :(得分:0)

由于省略了食谱name中的metadata.rb而得到此消息。添加name修复它。

我们所看到的信息显然是厨师的一个错误,希望很快得到解决,但与此同时,或许这可以帮助任何与我犯同样错误的人。