Introduction to Open Source Chef

Chef is a powerful automation platform that allows you to define your infrastructure as code to ensure that configurations are applied consistently in every environment, at any scale. Whether you’re operating in the cloud, on-premises, or in a hybrid environment, Chef automates how infrastructure is configured, deployed, and managed across your network, no matter its size.

Extended Documentation: Chef Overview

NEW! Download Chef Workstation

Infrastructure as Code

Chef code is made up of resources which each define a single configuration task that must be performed.

Resource Example

package 'nginx' do
  action :install
end

Chef resources are declarative by design, which means you tell Chef what action to take, and Chef dynamically takes platform-appropriate action automatically. Chef resources are also designed to be run continuously. Chef’s test-and-repair behavior means that configurations are only applied to systems that have diverged from their desired state. On properly configured systems, Chef simply confirms that configurations are up to date. Otherwise, Chef converges each system with their desired state, allowing you to apply configuration updates continuously, with confidence that Chef will only take action when it needs to.

Extended Documentation: Resources

Chef Cookbooks

Chef code is collected into purpose-specific artifacts called cookbooks. Each cookbook defines a configuration scenario and all the necessary components to support that scenario. Most cookbooks consist of:

  • Recipes: Ordered lists of Chef resources that describe an end-to-end configuration task
  • Attributes: User-defined variables that can be used to alter the behavior of a Chef recipe without needing to alter its underlying code
  • Files & Templates: Any static files or templates required for configuration tasks
  • metadata.rb: A metadata file used to ensure that each cookbook is correctly deployed to each node, providing support for cookbook versioning and dependency management

An Example Chef Recipe

Extended Documentation: Cookbooks

Testable Configurations

Chef Workstation includes everything you need to get started applying and creating Chef code, including a powerful testing harness called Test Kitchen. Test Kitchen integrates with multiple container, VM, and cloud provisioning frameworks to provide a simple workflow for creating, configuring, testing, and destroying ephemeral instances ensuring you can easily validate updates to your Chef code. Test Kitchen features built-in support for InSpec, Chef’s compliance automation framework, allowing you to evaluate test and development environments with the same rigor as your production fleet.

Extended Documentation: Test Kitchen

Learning Resources

Get started with Chef in minutes with our Chef Workstation getting started guide!

For more great learning resources, Learn Chef Rally is an invaluable library of self-paced tutorials and guides.

More Resources