Chef Cheat Sheet



Organizations

Chef: An Open Source Tool for Scalable Cloud and Data Center Automation by Jeffrey Hulten.pdf. Chef Natasha de Bourg from Below Deck Sailing Yacht softened her stance and truly took accountability for being defensive on the show. She said watching the show helped her to see that she was.

  • 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

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

  • Development
  • Test
  • Staging
  • Production
  • etc.

Every Organization starts with a single environment!

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

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

Marvelous designer mac. 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

Cheat

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:

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 Resource Cheat Sheet

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

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

  • Development
  • Test
  • Staging
  • Production
  • etc.

Every Organization starts with a single environment!

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

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 Download linkedin for mac.

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

Adobe illustrator cs5 for mac download. 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:

Data Bags

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

Chef Knife Cheat Sheet

Examples

4 Hour Chef Cheat Sheet

  • Users
  • Groups
  • Application Release Information