Chef Cheat Sheet: Complete Guide Tutorial | CHECK-OUT
Chef Cheat Sheet Tutorial

Chef Cheat Sheet: Complete Guide Tutorial For Free | CHECK-OUT

Last updated on 08th Jul 2020, Blog, Tutorials

About author

Pavithra Lakshmi (Data Scientist )

Pavithra Lakshmi has a wealth of experience in cloud computing, BI, Perl, Salesforce, Microstrategy, and Cobit. Moreover, she has over 9 years of experience as a data engineer in AI and can automate many of the tasks that data scientists and data engineers perform.

(5.0) | 19115 Ratings 1618

Chef is a Configuration management tool that manages the infrastructure by writing code rather than using a manual process so that it can be automated, tested and deployed very easily. Chef has Client-server architecture and it supports multiple platforms like Windows, Ubuntu, Centos, and Solaris etc.

  • Chef is an automation tool that provides a way to define infrastructure as code.
  • Infrastructure as code (IAC) simply means that managing infrastructure by writing code (Automating infrastructure) rather than using manual processes.
  • It can also be termed as programmable infrastructure. Chef uses a pure-Ruby, domain-specific language (DSL) for writing system configurations.
  • Below are the types of automation done by Chef, irrespective of the size of infrastructure:
  • Infrastructure configuration
  • Application deployment 
  • Configurations are managed across your network

Like Puppet which has a Master-Slave architecture even Chef has a Client-Server architecture. But Chef has an extra component called Workstation. I will talk about workstation in my next blog. Refer the diagram below:

  • In Chef, Nodes are dynamically updated with the configurations in the Server.
  • This is called Pull Configuration which means that we don’t need to execute even a single command on the Chef server to push the configuration on the nodes, nodes will automatically update themselves with the configurations present in the Server.
  • My next blog on Chef Tutorial will explain the Chef architecture along with all the Chef components in detail.

Now, let us look at reasons behind the popularity of Chef.

What Is Chef – Chef Key Metrics

  • Chef supports multiple platforms like AIX, RHEL/CentOS, FreeBSD, OS X, Solaris, Microsoft Windows and Ubuntu. Additional client platforms include Arch Linux, Debian and Fedora.
  • Chef can be integrated with cloud-based platforms such as Internap, Amazon EC2, Google Cloud Platform, OpenStack, SoftLayer, Microsoft Azure and Rackspace to automatically provision and configure new machines.
  • Chef has an active, smart and fast growing community support.
  • Because of Chef’s maturity and flexibility, it is being used by giants like Mozilla, Expedia, Facebook, HP Public Cloud, Prezi, Xero, Ancestry.com, Rackspace, Get Satisfaction, IGN, Marshall University, Socrata, University of Minnesota, Wharton School of the University of Pennsylvania, Bonobos, Splunk, Citi, DueDil, Disney, and Cheezburger.

“There are three dimensions of scale we generally look at for infrastructure — the number of servers, the volume of different configurations across those systems, and the number of people required to maintain those configurations.

  • Chef provided an automation solution flexible enough to bend to our scale dynamics without requiring us to change our workflow.”
  • Without a doubt Chef is one of the most famous Configuration Management tools and is closely competing with Puppet. But, before diving deep into “What is Chef”, it’s only fair that I first explain what is Configuration Management and why it is important.
Subscribe For Free Demo

[custom_views_post_title]

Configuration Management

Don’t worry, there won’t be any heavy definition of Configuration Management in this blog 🙂

Let us understand Configuration Management this way – suppose you have to deploy a software on top of hundreds of systems.

  • This software can be an operating system or a code or it can be an update of an existing software.
  • You can do this task manually, but what happens if you have to finish this task overnight because tomorrow might be a Big Billion Day sale in the company or some Mega Sale etc. in which heavy traffic is expected.
  • Even if you were able to do this manually there is a high possibility of multiple errors on your big day.
  • What if the software you updated on hundreds of systems is not working, then how will you revert back to the previous stable version, will you be able to do this task manually? AF-course not!
  • To solve this problem, Configuration Management was introduced.
  • By using Configuration Management tools like Chef, Puppet, etc. you can automate this task.
  • All you have to do is to specify the configurations in one centralized server and accordingly all the nodes will be configured.
  • It allows access to an accurate historical record of system state for project management and audit purposes.
  • So basically, we need to specify the configurations once on the central server and replicate that on thousands of nodes.
  • Configuration Management helps in performing the below tasks in a very structured and easy way:
  • Figuring out which components to change when requirements change.
  • Redoing an implementation because the requirements have changed since the last implementation.
  • Reverting to a previous version of the component if you have replaced with a new but flawed version.
  • Replacing the wrong component because you couldn’t accurately determine which component was supposed to be replaced.

There are broadly two ways to manage your configurations namely Push and Pull configurations.

  • Pull Configuration:  In this type of Configuration Management, the nodes poll a centralized server periodically for updates. These nodes are dynamically configured so basically they are pulling configurations from the centralized server. Pull configuration is used by tools like Chef, Puppet etc.
  • Push Configuration: In this type of Configuration Management, the centralized Server pushes the configurations to the nodes. Unlike Pull Configuration, there are certain commands that have to be executed in the centralized server in order to configure the nodes. Push Configuration is used by tools like Ansible.

What Is Chef – Configuration Management With Chef

  • We have understood what is Chef, now I will explain you how Chef achieves Configuration Management with a use-case.
  • Gannett is a publicly traded American media holding company. It is the largest U.S. newspaper publisher as measured by total daily circulation.
  • Gannett’s traditional deployment workflow was characterized by multiple handoffs and manual tests. Let us see what were the problems they faced with this process:
  • Maintaining accurate, repeatable builds was difficult.
  • There were many build failures and tests were often running in the wrong environments.
  • Deployment and provisioning times could range from a few days to several weeks.
  • Operations team didn’t have access to the cloud or development environments.
  • Every group used its own tool-set, and there was no accountability to finance or security. No one knew how much an application actually cost. Security had no way to audit the software stacks.

Gannett was ready for the change. Developers wanted to deploy their applications quickly. Operations wanted a stable infrastructure where they could build and deploy in a repeatable way. Finance wanted to know the true cost of an application. Security wanted to view and audit all stacks and to be able to track changes.

  • Gannett saw that cloud as a service offered many advantages.
  • Developers had access to standardized resources. It was easier to handle peaky traffic because of cloud’s compute-on-demand model, and handoffs were minimized.
  • Chef allows you to dynamically provision and de-provision your infrastructure on demand to keep up with peaks in usage and traffic.
  • It enables new services and features to be deployed and updated more frequently, with little risk of downtime. With Chef, you can take advantage of all the flexibility and cost savings that cloud offers. 

Let us see what were the functions performed by Chef at Gannett:

  • Gannett started building VPC (Virtual Private Cloud) for development environment that would mimic the production. None of the tools that they were already using were appropriate. But they found that Chef worked well with the cloud and both Linux and Windows environment. They used Chef to build a development environment that perfectly matched production environment.
  • For an application to move into the VPC, it had to be provisioned and deployed with Chef.
  • Security would be involved early on and would manage the mandatory controls for access to Chef and for maintaining system security standards.

Now is the time to understand what were the results of this process:

  • Gannett’s deployment became quicker and more reliable. Application provisioning and deployment, which once took weeks, after using Chef it took minutes.
  • All new applications were deployed on the cloud with Chef. These applications were deployed to all environments in the same way that they were deployed to production. Also, testing occurred in each environment, so that the deployments were reliable.
  • All infrastructure was treated as code, which greatly increases visibility into any changes that occurred. Development, Operations, Security and Finance all were benefited from this.
Course Curriculum

Get On-Demand Chef Training from Top-Rated Instructors

  • Instructor-led Sessions
  • Real-life Case Studies
  • Assignments
Explore Curriculum

Chef Terminology

Al dente

The literal translation from Italian is “at the tooth”, and refers to the perfect texture for cooking pasta, where the pasta still has a little firmness and ‘bite’ to it.

Amuse bouche

This refers to small, bite-size concoctions of food, which the Chef can present to their guests before the regular courses of the meal begin. The translation means “to amuse the mouth”.

Au gratin

Where a dish is sprinkled with grated cheese or breadcrumbs, and then browned.

Au jus

This is French for “with juice”, and means that the food item will be served with its natural juices (often referring to beef).

Basting

A cooking technique that involves brushing or coating a meat in its juices or an accompanying sauce. This helps keep the meat moist, and is especially useful when the meat is over heat for longer time periods, such as grilling a rack of ribs, or roasting a turkey in the oven.

Blind Baking

When pastry is baked before adding a filling.

Blanching

Where food is submerged in boiling water very briefly, then removed and plunged into iced water to halt the cooking process.

Braising

A cooking method where the food is seared at a high temperature for a short period of time, then cooked fully in a pot with liquid/other flavorings/ingredients.

Brining

A food is soaked in a salted water brine, usually to preserve it, or to enhance the flavor before cooking.

Broiling

A US term that refers to cooking with a heat source that is above the food, as opposed to grilling, which is when the heat source is below the food.

Butterfly

To split a food in half but not cutting the entire way through, instead folding out in a butterfly shape. This exposes more surface area to the heat source, and helps the food cook evenly and quickly.

Coddling

This is when food is heated in water to just below the boiling point.

Crimp

Where the edge of one or more pieces of dough is pinched together to seal together and form a decorative edge.

Deglaze

After a food has been cooked in a pan, a stock or other liquid can be added to the empty vessel over a high heat, and the bottom of the pan is gently scraped to release any flavor and color that is stuck to the bottom.

Double steaming

This is a Chinese cooking technique where a food is immersed in water, put into a jar, which is then steamed for several hours.

Fermentation

In addition to being a step in the brewing process of beer, this term can also be used in culinary situations to mean a preservation technique where sour foods can produce lactic acid in order to stay edible.

Fricassee

This is a way to cook meat which involves chopping it up, sautéeing, braising, and then serving it in its (traditionally white) sauce.

Ganache

A combination of cream or milk, mixed with melted chocolate, creating a soft consistency which does not re-set when cooled.

Organizations

  • Completely independent tenants of Enterprise Chef
  • Provide multi-tenancy in Enterprise Chef
  • Share nothing with other organizations
  • May represent different
  • Companies
  • Business Units
  • Departments
  • Each Organization may have multiple Users
  •  Manage an Organization’s Users via the Enterprise Server interface

Environments

ENVIRONMENT

Environments reflect your patterns and workflow, and can be used to model the life-stages of your application

  • Development
  • Test
  • Staging
  • Production
  • etc.

Environments may include data attributes necessary for configuring your infrastructure, e.g.

  • The URL of your payment service’s API
  • The location of your package repository
  • The version of the Chef configuration files that should be used
Course Curriculum

Enroll in Chef Certification Course Led By Industry Experts

Weekday / Weekend BatchesSee Batch Details

Roles

ROLES

Roles may include an ordered list of Chef configuration files that should be applied

  • This list is called a Run List
  • Order is always important in the Run List

Roles may include data attributes necessary for configuring your infrastructure, for example:

  • The port that the application server listens on
  • A list of applications that should be deployed

Node

Nodes represent the servers in your infrastructure

  • Could be physical servers or virtual servers
  • May represent hardware that you own or compute instances in a public or private cloud
  • Could also be network hardware – switches, routers, etc

Each Node will

  • Belong to one Organization
  • Belong to one Environment
  • Have zero or more Roles

The chef-client application runs on each node, which

  • Gathers the current system configuration of the node
  • Downloads the desired system configuration policies from the Chef server for that node
  • Configures the node such that it adheres to those policies

Resources

A Resource represents a piece of the system and its desired state

  • A package that should be installed
  • A service that should be running
  • A file that should be generated
  • A cron job that should be configured
  • A user that should be managed
  • and more

Resources are the fundamental building blocks of Chef configuration.Resources are gathered into Recipes. Recipes ensure the system is in the desired state

Recipes

  • Configuration files that describe resources and their desired state
  • Recipes can:
    • Install and configure software components
    • Manage files
    • Deploy applications
    • Execute other recipes
    • and more

Cookbooks

  • Recipes are stored in Cookbooks
  • Cookbooks contain recipes, templates, files, custom resources, etc
  • Code re-use and modularity
  • A cookbook is like a “package” for Chef recipes.
  • It contains all the recipes, files, templates, libraries, etc. required to configure a portion of your infrastructure
  • Typically they map 1:1 to a piece of software or functionality.

Run List

  • The Run List is an ordered collection of policies that the Node should follow
  • Chef-client obtains the Run List from the Chef Server
  • Chef-client ensures the Node complies with the policy in the Run List

Knife

Knife provides an API interface between a local Chef repository and the Chef Server, and lets you manage:

  • Nodes
  • Cookbooks and recipes
  • Roles
  • Stores of JSON data (data bags), including encrypted data
  • Environments
  • Cloud resources, including provisioning
  • The installation of Chef on management workstations
  • Searching of indexed data on the Chef Server

Node Objects

  • When you are writing Recipes, the Node object is always available to you.
  • Every node must have a unique name within an organization
  • Chef defaults to the Fully Qualified Domain Name of the server, i.e. in the format server.domain.com
  • Nodes are made up of Attributes •
    • Many are discovered automatically (platform, ip address, number of CPUs)
    • Many other objects in Chef can also add Node attributes (Cookbooks, Roles and Environments, Recipes, Attribute Files)
    • Nodes are stored and indexed on the Chef Server.

What are Attributes?

  • Attributes represent information about your node
  • The information can be autodetected from the node (e.g.# of CPUs, amount of RAM) & populated by Ohai
  • You can also set attributes on your node using cookbook recipes & attribute files, roles, environments, etc
  • Attributes keep the program code separate from data.
  • All attributes are set on the “node object”, and are indexed for search on the server

Attribute Sources Attributes can be set at various levels (in increasing order of precedence)

  • Automagically on the node itself (by Ohai)
  • In roles
  • In environments
  • In cookbook recipes
  • In cookbook attribute files

Attributes can be set in the cookbook’s attributes file ./cookbooks/<cookbook>/attributes/default.rb. The Format is In Recipes: 

ATTRIBUTES FORMAT
ATTRIBUTES FORMAT

Data Bags

A data bag is a container for items that represent information about your infrastructure that is not tied to a single node

Examples

  • Users
  • Groups
  • Application Release Information
Chef Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

Conclusion

If you ever desire to be a head Chef of your own restaurant, designing and pricing menu’s is an important skill to have if you are to succeed in the restaurant business.

If you would like continue this activity of being a personal chef, design a workflow plan for a dinner party and perhapes cook the menu you have designed for your family and friends! 

Furthermore, you could upload your menu design and start a blog to get feedback of your ideas. Perhapes you can organise your food technology class to start a blog page to share recipe ideas, strategies for cooking and workflow plans.

Are you looking training with Right Jobs?

Contact Us
Get Training Quote for Free