Search code examples
vagrantchef-infraberkshelfchefdk

Chefdk berkshelf and vagrant "found a directory cookbooks in the cookbook path, but it contains no cookbook files. skipping"


Main questions Why doesn't chef see cookbook files in the cookbook path? How can I solve it?

Installed already

  • rbenv
  • chefdk
  • vagrant-berkshelf plugin

Things I did already

put this in my .zshrc

eval "$(rbenv init -)"
export PATH="/opt/chefdk/bin:$PATH" 

Also did a berks install, and it works!

$ berks install
Resolving cookbook dependencies...
Fetching 'app' from source at .
Using app (0.1.0) from source at .
Using apt (2.6.0)
Using java (1.29.0)
Using rbenv (0.7.2) from git://github.com/fnichol/chef-rbenv.git (at v0.7.2)
Using ruby_build (0.8.0) from git://github.com/fnichol/chef-ruby_build.git (at v0.8.0)

Vagrant provision (the error):

$ vagrant provision
==> default: Loading Berkshelf datafile...
==> default: Sharing cookbooks with VM
==> default: Couldn't find Cheffile at ./Cheffile.
==> default: Updating Vagrant's Berkshelf...
==> default: Resolving cookbook dependencies...
==> default: Fetching 'app' from source at .
==> default: Using app (0.1.0) from source at .
==> default: Using java (1.29.0)
==> default: Using ruby_build (0.8.0) from git://github.com/fnichol/chef-ruby_build.git (at v0.8.0)
==> default: Using apt (2.6.0)
==> default: Using rbenv (0.7.2) from git://github.com/fnichol/chef-rbenv.git (at v0.7.2)
==> default: Vendoring app (0.1.0) to /Users/****/.berkshelf/vagrant-berkshelf/shelves/berkshelf20141128-98987-1p3n8pb-default/app
==> default: Vendoring apt (2.6.0) to /Users/****/.berkshelf/vagrant-berkshelf/shelves/berkshelf20141128-98987-1p3n8pb-default/apt
==> default: Vendoring java (1.29.0) to /Users/****/.berkshelf/vagrant-berkshelf/shelves/berkshelf20141128-98987-1p3n8pb-default/java
==> default: Vendoring rbenv (0.7.2) to /Users/****/.berkshelf/vagrant-berkshelf/shelves/berkshelf20141128-98987-1p3n8pb-default/rbenv
==> default: Vendoring ruby_build (0.8.0) to /Users/****/.berkshelf/vagrant-berkshelf/shelves/berkshelf20141128-98987-1p3n8pb-default/ruby_build
==> default: Chef 12.0.1 Omnibus package is already installed.
==> default: Running provisioner: chef_solo...
Generating chef JSON and uploading...
==> default: Running chef-solo...
==> default: stdin: is not a tty
==> default: [2014-12-12T13:42:11+00:00] INFO: Forking chef instance to converge...
==> default: [2014-12-12T13:42:11+00:00] INFO: *** Chef 12.0.1 ***
==> default: [2014-12-12T13:42:11+00:00] INFO: Chef-client pid: 10274
==> default: [2014-12-12T13:42:17+00:00] INFO: Setting the run_list to ["recipe[app]", "recipe[ruby_build]", "recipe[rbenv::user]", "recipe[rbenv::user_install]", "recipe[rbenv::vagrant]"] from CLI options
==> default: [2014-12-12T13:42:17+00:00] INFO: Run List is [recipe[app], recipe[ruby_build], recipe[rbenv::user], recipe[rbenv::user_install], recipe[rbenv::vagrant]]
==> default: [2014-12-12T13:42:17+00:00] INFO: Run List expands to [app, ruby_build, rbenv::user, rbenv::user_install, rbenv::vagrant]
==> default: [2014-12-12T13:42:17+00:00] INFO: Starting Chef Run for app-berkshelf
==> default: [2014-12-12T13:42:17+00:00] INFO: Running start handlers
==> default: [2014-12-12T13:42:17+00:00] INFO: Start handlers complete.
==> default: [2014-12-12T13:42:17+00:00] WARN: found a directory cookbooks in the cookbook path, but it contains no cookbook files. skipping.
==> default: [2014-12-12T13:42:17+00:00] WARN: found a directory tmp in the cookbook path, but it contains no cookbook files. skipping.
==> default: [2014-12-12T13:42:17+00:00] WARN: found a directory vagrant-berkshelf in the cookbook path, but it contains no cookbook files. skipping.
==> default: [2014-12-12T13:42:17+00:00] ERROR: Running exception handlers
==> default: [2014-12-12T13:42:17+00:00] ERROR: Exception handlers complete
==> default: [2014-12-12T13:42:17+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2014-12-12T13:42:17+00:00] ERROR: Cookbook app not found. If you're loading app from another cookbook, make sure you configure the dependency in your metadata
==> default: [2014-12-12T13:42:17+00:00] FATAL: Chef::Exceptions::ChildConvergeError: 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.

If you want more info please ask.

update add vagrant file:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"

Vagrant.require_version ">= 1.5.0"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.hostname = "app-berkshelf"
  config.vm.box = "chef/ubuntu-14.04"

  # Assign this VM to a host-only network IP, allowing you to access it
  # via the IP. Host-only networks can talk to the host machine as well as
  # any other machines on the same network, but cannot be accessed (through this
  # network interface) by any external networks.
  config.vm.network :private_network, type: "dhcp"

  # The path to the Berksfile to use with Vagrant Berkshelf
  config.berkshelf.berksfile_path = "./Berksfile"

  # Enabling the Berkshelf plugin. To enable this globally, add this configuration
  # option to your ~/.vagrant.d/Vagrantfile file
  config.berkshelf.enabled = true

  # get latest chef
  config.omnibus.chef_version = :latest

  config.vm.provision :chef_solo do |chef|
    chef.custom_config_path = "Vagrantfile.chef"

    chef.json = {
      'rbenv' => {
        'user_installs' => [
          { 'user'    => 'vagrant',
            'rubies'  => ['1.9.3-p551'],
            'global'  => '1.9.3-p551',
            'gems'    => {
              '1.9.3' => [
                { 'name' => 'bundler' }
              ]
            }
          }
        ]
      }
    }

    chef.run_list = [
        'recipe[app]',
        'recipe[ruby_build]',
        'recipe[rbenv::user]',
        'recipe[rbenv::user_install]',
        'recipe[rbenv::vagrant]'
    ]
  end
end

Update metadata.rb added

name             'app'
maintainer       'YOUR_NAME'
maintainer_email 'YOUR_EMAIL'
license          'All rights reserved'
description      'Installs/Configures app'
long_description 'Installs/Configures app'
version          '0.1.0'

Solution

  • Seems like the vagrant-berkshelf plugin is outdated.

    See: https://sethvargo.com/the-future-of-vagrant-berkshelf/