Project

berksfiler

0.0
No commit activity in last 3 years
No release in over 3 years
Programatically generate Berksfiles for Chef cookbooks.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0

Runtime

 Project Readme

Berksfiler

Build Status Gem Version

Berksfiler programatically generates Berkshelf Berksfiles for your Chef cookbooks.

Overview

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.

Requirements

  • A working knife toolchain

Installation

$ gem install berksfiler

Configuration

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
common_cookbooks:
 - 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.
 excluded_cookbooks:
 - 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.
cookbook_options:
 -
  name: artifact
  options: "git: 'git://github.com/CozyCo/artifact-cookbook.git'"

Usage

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.

Example

Given a set of local cookbooks:

/cookbooks
  /foo
  /bar
  /baz

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 'https://supermarket.chef.io'
metadata

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

# Dependencies of this cookbook
cookbook 'artifact', git:  'git://github.com/CozyCo/artifact-cookbook.git'
cookbook 'bar',      path: '../bar'
cookbook 'baz',      path: '../baz'

Copyright

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