Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

undefined method "cheffish" for nil:NilClass, when provisioning chef with vagrant

I'm trying to run a django-server in a Vagrant box using Chef, but I've been stuck on this for a few hours and can't find anything online. The relevant bit of my vagrantfile looks like this: (sorry for the poor indentation) Also, the box is running 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

And I get this error when I run 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.

What really confuses me is that I can't find any references to cheffish anywhere in any of these cookbooks.

I've tried eliminating all chef.add_recipe lines except ohai, and alternatively yum, but I still get the same error. (I am running vagrant reload and vagrant provision between tries. I've also tried sshing into the box, removing the cheffish gem, running vagrant provision, and reinstalling the cheffish gem and running vagrant provision, but to no avail.

like image 208
agarrow Avatar asked Jun 30 '15 22:06

agarrow


3 Answers

Finally got it. As pointed out in the comments this problem is introduced in chef v. 12.4.0, I added the line chef.version = "12.3.0" to the provision block and now it's working.

like image 96
agarrow Avatar answered Oct 14 '22 09:10

agarrow


The error for me was related to two custom cookbooks that someone how had the same name in metadata.rb correcting it fixed it.

like image 1
Michael Ruxsaksriskul Avatar answered Oct 14 '22 08:10

Michael Ruxsaksriskul


for me the solution was to make sure every cookbook I was using had a "name" attribute in it with the name of the cookbook. 'redis', 'install_from', and 'metachef' cookbooks were all missing the name field from the metadata.rb

chef-client v12.3.0 helped uncover this, 12.4.1 was not showing me anything useful

like image 1
rojomisin Avatar answered Oct 14 '22 10:10

rojomisin