Berkshelf is a cookbook dependency manager.
Assuming you have already installed the chef development kit, first generate a cookbook:
$ chef generate cookbook demo
$ tree
.
└── demo
├── Berksfile
├── chefignore
├── metadata.rb
├── README.md
├── recipes
│ └── default.rb
├── spec
│ ├── spec_helper.rb
│ └── unit
│ └── recipes
│ └── default_spec.rb
└── test
└── integration
├── default
│ └── serverspec
│ └── default_spec.rb
└── helpers
└── serverspec
└── spec_helper.rb
The Berksfile holds the configuration and its format is documented on the website. The cookbook generator creates a default setting that tells berkshelf to download dependencies from the Chef supermarket and to use the metadata file to list those dependencies:
source 'https://supermarket.chef.io'
metadata
So let's edit the metadata.rb file adding mysql as a dependency
name 'demo'
maintainer 'The Authors'
maintainer_email 'you@example.com'
license 'all_rights'
description 'Installs/Configures demo'
long_description 'Installs/Configures demo'
version '0.1.0'
depends "mysql"
So now if you decide to run berkshelf, it will resolve your cookbook's dependencies for you automatically.
$ berks vendor cookbooks
Resolving cookbook dependencies...
Fetching 'demo' from source at .
Using demo (0.1.0) from source at .
Using mysql (8.1.1)
Vendoring demo (0.1.0) to cookbooks/demo
Vendoring mysql (8.1.1) to cookbooks/mysql
Hopefully this answers some of your questions, but to conclude could I recommend that you look at test kitchen? The cookbook generator also configures this to use Vagrant to both run chef and test your cookbook at the same time:
$ kitchen test default-ubuntu-1404
Be a happy Chef!