Skip to content

Files

Latest commit

 

History

History
358 lines (317 loc) · 14.4 KB

chef_overview.md

File metadata and controls

358 lines (317 loc) · 14.4 KB

+++ title = "An Overview of Chef Infra" draft = false

aliases = ["/chef_overview.html"]

[menu] [menu.docs] title = "Chef Infra Overview" identifier = "chef_infra/getting_started/chef_overview.md Chef Infra Overview" parent = "chef_infra/getting_started" weight = 10 +++

[edit on GitHub]

{{% chef %}}

  • Chef Workstation is the location where users interact with Chef Infra. With Chef Workstation, users can author and test cookbooks using tools such as Test Kitchen and interact with the Chef Infra Server using the knife and chef command line tools.
  • Chef Infra Client nodes are the machines that are managed by Chef Infra. The Chef Infra Client is installed on each node and is used to configure the node to its desired state.
  • Chef Infra Server acts as a hub for configuration data. Chef Infra Server stores cookbooks, the policies that are applied to nodes, and metadata that describes each registered node that is being managed by Chef. Nodes use the Chef Infra Client to ask the Chef Infra Server for configuration details, such as recipes, templates, and file distributions.

Chef Infra Components

The following diagram shows the relationships between the various elements of Chef Infra, including the nodes, the server, and the workstation. These elements work together to provide the Chef Infra Client the information and instruction that it needs so that it can do its job. As you are reviewing the rest of this topic, use the icons in the tables to refer back to this image.

image

Chef Infra has the following major components:

Component Description

image

image

image

One (or more) workstations are configured to allow users to author, test, and maintain cookbooks.

Workstation systems run the Chef Workstation package which includes tools such as Chef Infra Client, Chef InSpec, Test Kitchen, ChefSpec, Cookstyle, and other tools necessary for developing and testing your infrastructure with Chef products.

Cookbooks are uploaded to the Chef Infra Server from these workstations. Some cookbooks are custom to the organization and others are based on community cookbooks available from the Chef Supermarket.

Ruby is the programming language that is the authoring syntax for cookbooks. Most recipes are simple patterns (blocks that define properties and values that map to specific configuration items like packages, files, services, templates, and users. The full power of Ruby is available for when you need a programming language.

image

image

{{% node %}}

Chef Infra Client is installed on each node that is managed with Chef Infra. Chef Infra Client configures the node locally by performing the tasks specified in the run-list. Chef Infra Client will also pull down any required configuration data from the Chef Infra Server during a Chef Infra Client run.

image

The Chef Infra Server acts as a hub of information. Cookbooks and policy settings are uploaded to the Chef Infra Server by users from workstations. (Policy settings may also be maintained from the Chef Infra Server itself, via the Chef management console web user interface.)

The Chef Infra Client accesses the Chef Infra Server from the node on which it's installed to get configuration data, performs searches of historical Chef Infra Client run data, and then pulls down the necessary configuration data. After a Chef Infra Client run is finished, the Chef Infra Client uploads updated run data to the Chef Infra Server.

image Chef Supermarket is the location in which community cookbooks are shared and managed. Cookbooks that are part of the Chef Supermarket may be used by any Chef user. How community cookbooks are used varies from organization to organization.

Chef Infra Client run reporting, compliance reporting, high availability configurations, and Chef Infra Server replication are available as part of Chef Automate.

The following sections discuss these elements (and their various components) in more detail.

Workstations

A workstation is your local computer running Chef Workstation that you use to author cookbooks, interact with the Chef Infra Server, and interact with nodes.

The workstation is where users do most of their work, including:

  • Developing and testing cookbooks and recipes
  • Testing Chef code
  • Keeping the Chef repository synchronized with version source control
  • Configuring organizational policy, including defining roles and environments, and ensuring that critical data is stored in data bags
  • Interacting with nodes, as (or when) required, such as performing a bootstrap operation

Chef Workstation Components and Tools

Some important tools and components of Chef Workstation include:

Component Description
image {{% chef_workstation %}}

image

image

Chef Workstation includes important command-line tools:

  • Chef Infra: Use the chef command-line tool to work with items in a chef-repo, which is the primary location in which cookbooks are authored, tested, and maintained, and from which policy is uploaded to the Chef Infra Server
  • Knife: Use the knife command-line tool to interact with nodes or work with objects on the Chef Infra Server
  • Chef Infra Client: an agent that configures your nodes
  • Test Kitchen: a testing harness for rapid validation of Chef code
  • Chef InSpec: Chef's open source security & compliance automation framework
  • chef-run: a tool for running ad-hoc tasks
  • Chef Workstation App: for updating and managing your chef tools

image

The chef-repo is the repository structure in which cookbooks are authored, tested, and maintained:

  • Cookbooks contain recipes, attributes, custom resources, libraries, files, templates, tests, and metadata
  • The chef-repo should be synchronized with a version control system (such as git), and then managed as if it were source code

The directory structure within the chef-repo varies. Some organizations prefer to keep all of their cookbooks in a single chef-repo, while other organizations prefer to use a chef-repo for every cookbook.

image {{% test_kitchen %}}
image {{% chefspec_summary %}}

Cookbooks

{{% cookbooks_summary %}}

The Chef Infra Client uses Ruby as its reference language for creating cookbooks and defining recipes, with an extended DSL for specific resources. A reasonable set of resources are available to the Chef Infra Client, enough to support many of the most common infrastructure automation scenarios; however, this DSL can also be extended when additional resources and capabilities are required.

Components

Cookbooks are comprised of the following components:

Component Description
image {{% cookbooks_attribute %}}
image {{% resource_cookbook_file_summary %}}
image {{% libraries_summary %}}
image {{% cookbooks_metadata %}}

image

image

{{% cookbooks_recipe %}}

The Chef Infra Client will run a recipe only when asked. When the Chef Infra Client runs the same recipe more than once, the results will be the same system state each time. When a recipe is run against a system, but nothing has changed on either the system or in the recipe, the Chef Infra Client won't change anything.

{{% dsl_recipe_summary %}}

image

{{% resources_common %}}

Chef has many built-in resources that cover all of the most common actions across all of the most common platforms. You can build your own resources to handle any situation that isn't covered by a built-in resource.

image {{% template %}}
image Testing cookbooks improves the quality of those cookbooks by ensuring they are doing what they are supposed to do and that they are authored in a consistent manner. Unit and integration testing validates the recipes in cookbooks. Syntax testing---often called linting---validates the quality of the code itself. The following tools are popular tools used for testing Chef recipes: Test Kitchen, ChefSpec, and Cookstyle.

Nodes

{{% node %}}

Node Types

{{% node_types %}}

Chef on Nodes

The key components of nodes that are under management by Chef include:

Component Description

image

{{% chef_client_summary %}}

{{% security_key_pairs_chef_client %}}

image {{% ohai_summary %}}

The Chef Infra Server

{{% chef_server %}}

Feature Description
image {{% search %}}
image {{% chef_manager %}}
image {{% data_bag %}}
image Policy defines how business and operational requirements, processes, and production workflows map to objects that are stored on the Chef Infra Server. Policy objects on the Chef Infra Server include roles, environments, and cookbook versions.

Policy

{{% policy_summary %}}

Some important aspects of policy include:

Feature Description
image {{% role %}}
image {{% environment %}}
image {{% cookbooks_version %}}
image {{% node_run_list %}}

Conclusion

Chef is a thin DSL (domain-specific language) built on top of Ruby. This approach allows Chef to provide just enough abstraction to make reasoning about your infrastructure easy. Chef includes a built-in taxonomy of all the basic resources one might configure on a system, plus a defined mechanism to extend that taxonomy using the full power of the Ruby language. Ruby was chosen because it provides the flexibility to use both the simple built-in taxonomy, as well as being able to handle any customization path your organization requires.