Introduction
Chef is a powerful automation platform that transforms complex infrastructure into code, enabling your data center infrastructure automation using a declarative, intent-based model. Whether you're operating in the cloud, on-premises, or a hybrid, Chef automates how applications are configured, deployed, and managed across your network, no matter its size.
Chef is built around simple concepts: achieving desired state, centralized modeling of IT infrastructure, and resource primitives that serve as building blocks. These concepts enable you to quickly manage any infrastructure with Chef. These very same concepts allow Chef to handle the most difficult infrastructure challenges and customer use-cases, anything that can run the chef-client can be managed by Chef.
Key Technical Concepts
Chef Server
The Chef server acts as a hub for configuration data. It stores:
- Cookbooks
- Recipes (The policies that are applied to nodes)
- Metadata that describes each registered node that is being managed by the chef-client
Node
Any physical, virtual, or cloud machine or switch configured to be maintained by a chef-client.
Chef Client
Runs locally on every node that is registered with the Chef server. Performs all configuration tasks specified by the run-list and brings client into desired state.
Chef Resources
Term used for a grouping of managed objects/attributes and one or more corresponding implementations. It describes the desired state for a configuration item and declares the steps needed to bring that item to the desired state. It specifies a resource type—such as a package, template or service, and lists additional details (also known as attributes), as necessary. These are grouped into recipes, which describe working configurations
The 2 core layers of a resource:
- Resource Type: Definition of managed objects.
- Resource Provider: Implementation of management tasks on objects.
Cookbook
A cookbook defines a scenario and contains everything that is required to support that scenario, and is used for device configuration and policy distribution:
- Recipes that specify the resources to use and the order in which they are to be applied
- Attribute values
- File distributions
- Templates
- Extensions to Chef, such as libraries, definitions, and custom resources
Recipe
A collection of resources, defined using patterns (resource names, attribute-value pairs, and actions); helper code is added around this using Ruby:
- Must be stored in a cookbook
- May use the results of a search query and read the contents of a data bag
- May have a dependency on one (or more) recipes
- Must be added to a run-list before it can be used by the chef-client
- Is always executed in the same order as listed in a run-list
- The chef-client will run a recipe only when asked
Sample Cookbook Showing Configuration of Switch Interface as L3 or L2:
Chef Reference Links
Cisco Chef Client: ( WRL5 Agent, CentOS7 Agent for Guest Shell )
Cisco Chef Cookbook: ( https://supermarket.chef.io/cookbooks/cisco-cookbook )
Cisco Chef Cookbook Source Repository ( https://github.com/cisco/cisco-network-chef-cookbook )
List of Supported Cisco Resources ( https://github.com/cisco/cisco-network-chef-cookbook/blob/develop/README.md#resource-by-tech )