Programatically generate Berksfiles for your Chef cookbooks.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Build Status Gem Version

Berksfiler programatically generates Berkshelf Berksfiles for your Chef cookbooks.


This tool is designed to help people who have monolithic cookbook repositories generate Berksfiles for their cookbooks. Keeping Berksfiles up to date can be a demanding task, especially when they reference a number of other local cookbooks.

Berksfiler can iterate through a /cookbooks directory and generate a Berksfile for each cookbook in that directory (with configurable exclusions), or it can generate Berksfiles for individual cookbooks.

It runs knife deps to determine the full dependency tree for a cookbook. It then generates a Berksfile that includes all local cookbook dependencies, as well as any cookbooks with manually-specified options or sources.

You can configure Berksfiler to include specific cookbook dependencies in every Berksfile. This is useful for cookbook dependencies that are used for local development (eg. chef-solo-search) but are not appropriate to include in the metadata of your cookbooks.


  • A working knife toolchain


$ gem install berksfiler


Berksfiler expects a .berksfiler.yml in your working directory (the root of your chef repository).

Heres an example of a config file with all available options:

# A relative or absolute path to the location of your cookbooks directory.
cookbooks_root: cookbooks

# An array of cookbooks to include in every Berksfile
# even if cookbook metadata doesn't specify them
 - chef-solo-search

# An array of local cookbooks for which we should not attempt
# to overwrite the existing Berksfile. Useful for 3rd party
# or vendored cookbooks for which we don't want to overwrite
# an existing Berksfile.
 - jenkins

# An array of hashes that specify options for cookbooks.
# All array elements must have string keys 'name' and 'options'.
# Options will be appended verbatim to the `cookbook` line
# in the Berksfile for the named cookbook.
  name: artifact
  options: "git: 'git://'"


Usage: berksfiler [options]
    -b, --books COOKBOOK,COOKBOOK    Cookbooks for which to generate Berksfiles
    -c, --config-file FILE           Path to config file
    -h, --help                       Displays Help

Running berksfiler without the --books option will cause Berksfiler to generate new Berksfiles for all cookbooks in the configured cookbooks_root directory, except for any cookbooks specified in the excluded_cookbooks config option.

Berksfiler should be run from the root of your Chef repository.


Given a set of local cookbooks:


assuming /cookbooks/foo/metadata.rb contains the following dependencies:

depends 'artifact'
depends 'bar'
depends 'baz'
depends 'some_public_cookbook'
depends 'some_other_public_cookbook'

and using the example config file displayed above, running:

$ berksfiler -b foo

would create or update the file /cookbooks/foo/Berksfile with the following content:

# Autogenerated by Berksfiler, do not edit

source ''

# Common dependencies for all Berksfiles
cookbook 'chef-solo-search'

# Dependencies of this cookbook
cookbook 'artifact', git:  'git://'
cookbook 'bar',      path: '../bar'
cookbook 'baz',      path: '../baz'


Copyright (c) 2014-2015 Matt Greensmith and Cozy Services Ltd. See LICENSE.txt for further details.