Chef

About CookbooksΒΆ

A cookbook is the fundamental unit of configuration and policy distribution. Each cookbook defines a scenario, such as everything needed to install and configure MySQL, and then it contains all of the components that are required to support that scenario, including:

  • Attribute values that are set on nodes
  • Definitions that allow the creation of reusable collections of resources
  • File distributions
  • Libraries that extend the chef-client and/or provide helpers to Ruby code
  • Recipes that specify which resources to manage and the order in which those resources will be applied
  • Custom resources and providers
  • Templates
  • Versions
  • Metadata about recipes (including dependencies), version constraints, supported platforms, and so on
Components Description
Cookbooks Maintained by Chef Chef maintains a collection of cookbooks that are important and are widely used by the community.
Community-authored Cookbooks The community has authored thousands of cookbooks, ranging from niche cookbooks that are used by only a few organizations, to cookbooks that are used by nearly everyone.
Recipes A recipe is the most fundamental configuration element.
Cookbooks Directory Structure The cookbooks/ directory is used to store the cookbooks that are used by the chef-client when configuring the various systems in the organization.
Resources and Providers A resource is a package, a service, a group of users, and so on. A resource tells the chef-client which provider to use during a chef-client run for various tasks like installing packages, running Ruby code, or accessing directories and file systems. The resource is generic: “install program A” while the provider knows what to do with that process on Debian and Ubuntu and Microsoft Windows. A provider defines the steps that are required to bring that piece of the system into the desired state. The chef-client includes default providers that cover all of the most common scenarios.
Lightweight Resources A lightweight resource is a custom resource that creates an abstract approach for defining a set of actions and (for each action) a set of attributes and validation parameters.
Attribute Files An attribute can be defined in a cookbook (or a recipe) and then used to override the default settings on a node.
Definitions A definition is used to create new resources by stringing together one (or more) existing resources.
Files A file distribution is a specific type of resource that tells a cookbook how to distribute files, including by node, by platform, or by file version.
Libraries A library allows the use of arbitrary Ruby code in a cookbook, either as a way to extend the chef-client language or to implement a new class.
Metadata A metadata file is used to ensure that each cookbook is correctly deployed to each node.
Templates A template is a file written in markup language that uses Ruby statements to solve complex configuration scenarios.
Versions A cookbook version represents a specific set of functionality that is different from the cookbook on which it is based.