LinuxCommandLibrary

berks

Manage and resolve cookbook dependencies for Chef

TLDR

Install cookbook dependencies into a local repo

$ berks install
copy

Update a specific cookbook and its dependencies
$ berks update [cookbook]
copy

Upload a cookbook to the Chef server
$ berks upload [cookbook]
copy

View the dependencies of a cookbook
$ berks contingent [cookbook]
copy

SYNOPSIS

berks [COMMAND] [options] [args]

PARAMETERS

-h, --help
    Show help for command or subcommand

-v, --version
    Display Berkshelf version

--berkshelf-path PATH
    Set path to Berkshelf directory

--format FORMAT
    Output format (human, json, shell)

--log-level LEVEL
    Set log level (debug, info, warn, error)

--no-git
    Disable Git dependency resolution

--no-progress
    Disable progress bars

--only ENV
    Resolve only for specified environments

--path PATH
    Set path for cookbook operations

--verbose
    Enable verbose logging

DESCRIPTION

The berks command is the CLI interface for Berkshelf, a tool designed to manage cookbook dependencies in Chef infrastructure automation projects. It treats cookbooks like gems, using a Berksfile to declare dependencies much like a Gemfile in Ruby projects.

Key workflows include initializing a Berksfile with berks init, installing dependencies into a local Berkshelf with berks install, vendoring cookbooks for offline use via berks vendor, and uploading resolved cookbooks to a Chef Server using berks upload. It handles transitive dependencies, locking versions in a Berksfile.lock, and supports multiple environments.

Berkshelf streamlines collaboration by ensuring reproducible cookbook sets across teams. However, it requires the Berkshelf Ruby gem (part of Chef Development Kit) and is primarily used in legacy Chef setups. Integration with Git and various cookbook sources like Supermarket enhances its utility for large-scale deployments.

CAVEATS

Berkshelf is deprecated since Chef 13 (2017); migrate to Policyfiles for new projects.
Requires Ruby >= 2.2 and Berkshelf gem. Not a core Linux utility.

KEY SUBCOMMANDS

init: Create Berksfile.
install: Install dependencies.
upload: Upload to Chef Server.
vendor: Vendor to path.
list: List installed cookbooks.

BERKSFILE EXAMPLE

source 'https://supermarket.chef.io'
cookbook 'apt', '>= 2.0'
cookbook 'nginx', git: 'https://github.com/chef-cookbooks/nginx.git'

HISTORY

Developed by Reset in 2011 as Berkshelf gem; acquired by Chef Software in 2013. Widely used until deprecated in Chef 13 (2017) favoring Policyfiles for dependency management.

SEE ALSO

chef-client(8), knife(1), bundler(1)

Copied to clipboard