PacktLib: Chef Infrastructure Automation Cookbook

Chef Infrastructure Automation Cookbook



About the Author

About the Reviewers


Chef Infrastructure


Using version control

Installing Chef on your workstation

Using the Hosted Chef platform

Managing virtual machines with Vagrant

Creating and using cookbooks

Inspecting files on your Chef Server with Knife

Defining cookbook dependencies

Managing cookbook dependencies with Berkshelf

Downloading and integrating cookbooks as vendor branches into your Git repository

Using custom Knife plugins

Changing organizations based on the current Git branch

Deleting a node from the Chef Server

Running Chef Solo

Using roles

Using environments

Freezing cookbooks

Running Chef Client as a daemon

Using the Chef console (Chef Shell)

Evaluating and Troubleshooting Cookbooks and Chef Runs


Testing your Chef cookbooks

Flagging problems in your Chef cookbooks

Test Driven Development for cookbooks using ChefSpec

Integration testing your cookbooks with Test Kitchen

Showing affected nodes before uploading cookbooks

Overriding a node's run list to execute a single recipe

Using why-run mode to find out what a recipe might do

Debugging Chef Client runs

Inspecting results of your last ChefClient run

Raising and logging exceptions in recipes

Diffing cookbooks with knife

Using community exception and report handlers

Creating custom handlers

Chef Language and Style


Using community Chef style

Using attributes to dynamically configure recipes

Using templates

Mixing plain Ruby with Chef DSL

Installing Ruby gems and using them in recipes

Using libraries

Using definitions

Creating your own Light Weight Resource Providers (LWRP)

Extending community cookbooks by using application wrapper cookbooks

Creating custom Ohai plugins

Creating custom Knife plugins

Writing Better Cookbooks


Setting environment variables

Passing arguments to shell commands

Overriding attributes

Using search to find nodes

Using data bags

Using search to find data bag items

Using encrypted data bag items

Accessing data bag values from external scripts

Getting information about the environment

Writing cross-platform cookbooks

Finding the complete list of operating systems you can use in cookbooks

Making recipes idempotent by using conditional execution

Working with Files and Packages


Creating configuration files using templates

Using pure Ruby in templates for conditionals and iterations

Installing packages from a third-party repository

Installing software from source

Running a command when a file is updated

Distributing directory trees

Cleaning up old files

Distributing different files based on the target platform

Users and Applications


Creating users from data bags

Securing the Secure Shell Daemon (SSHD)

Enabling passwordless sudo

Managing NTP

Managing nginx

Creating nginx sites

Creating MySQL databases and users

Managing WordPress sites

Managing Ruby on Rails applications

Managing Varnish

Managing your workstation

Servers and Cloud Infrastructure


Creating cookbooks from a running system with Blueprint

Running the same command on many machines at once

Setting up SNMP for external monitoring services

Deploying a Nagios monitoring server

Building high-availability services using Heartbeat

Using HAProxy to load-balance multiple web servers

Using custom bootstrap scripts

Managing firewalls with iptables

Managing fail2ban to ban malicious IP addresses

Managing Amazon EC2 instances

Loading your Chef infrastructure from a file with spiceweasel and Knife