O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chef: Powerful Infrastructure Automation

Book Description

Learn Chef Provisioning like a boss and discover how to deploy software and manage hosts, along with engaging recipes to automate your cloud and server infrastructure with Chef.

About This Book

  • Leverage the power of Chef to transform your infrastructure into code to deploy new features in minutes
  • Get step-by-step instructions to configure, deploy, and scale your applications
  • Master specific Chef techniques to run an entire fleet of machines without breaking a sweat.

Who This Book Is For

If you are a system administrator, Linux administrator, a cloud developer, or someone who just wants to learn and apply Chef automation to your existing or new infrastructure, then this learning path will show you all you need to know. In order to get the most out of this learning path, some experience of programming or scripting languages would be useful.

What You Will Learn

  • Install Chef server on your own hosts
  • Integrate Chef with cloud services
  • Debug your cookbooks and Chef runs using the numerous inspection and logging facilities of Chef
  • Extend Chef to meet your advanced needs by creating custom plugins for Knife and Ohai
  • Create a perfect model system
  • Use the best test-driven development methodologies

In Detail

Chef is a configuration management tool that turns IT infrastructure into code. Chef provides tools to manage systems at scale. This learning path takes you on a comprehensive tour of Chef's functionality, ranging from its core features to advanced development. You will be brought up to speed with what's new in Chef and how to set up your own Chef infrastructure for individuals, or small or large teams. You will learn to use the basic Chef command-line tools. We will also take you through the core concepts of managing users, applications, and your entire cloud infrastructure. You will learn the techniques of the pros by walking you through a host of step-by-step guides to solve real-world infrastructure automation challenges.You will learn to automate and document every aspect of your network, from the hardware to software, middleware, and all your containers. You will become familiar with the Chef'sProvisioning tool. By the end of this course, you will be confident in how to manage your infrastructure, scale using the cloud, and extend the built-in functionality of Chef itself.The books used in this Learning Path are:

1) Chef Essentials

2) Chef Infrastructure Automation Cookbook – Second Edition

3) Mastering Chef Provisioning

Style and approach

This fast-paced guide covers the many facets of Chef and will teach administrators to use Chef as a birds-eye lens for their entire system. This book takes you through a host of step-by-step guides to solve real-world infrastructure automation challenges and offers elegant, time-saving solutions for a perfectly described and automated network.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Chef: Powerful Infrastructure Automation
    1. Table of Contents
    2. Chef: Powerful Infrastructure Automation
    3. Chef: Powerful Infrastructure Automation
    4. Credits
    5. Preface
      1. What this learning path covers
      2. What you need for this learning path
      3. Who this learning path is for
      4. Reader feedback
      5. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    6. 1. Module 1
      1. 1. Installing Chef
        1. Terminology
        2. Working with Chef
          1. Installing chef-solo
          2. The Ruby gem
          3. Managing gems
          4. Verifying that chef-solo works
        3. Installing a Chef server
          1. Requirements and recent changes
          2. Installation requirements
          3. What you will be installing
          4. Getting the installer
          5. Installation outline
          6. Installing on Ubuntu
            1. Downloading the package
            2. Installing the package
          7. Installing on Red Hat Enterprise Linux
            1. Downloading the package
        4. Configuring a Chef server
          1. Understanding how chef-server-ctl works
          2. What's happening on my server?
          3. Verifying that the services are running
        5. Validating that your service is working
          1. Ensuring that your knife configuration works
        6. Summary
      2. 2. Modeling Your Infrastructure
        1. Getting to know Chef
        2. Modeling your infrastructure
          1. Roles
            1. Defining roles
              1. A web application service role
              2. An image-processing role
              3. An image search role
              4. A PostgreSQL service role
              5. A Solr service role
              6. An OpenSSH service role
          2. Implementing a role
          3. Determining which recipes you need
            1. Installing a cookbook
          4. Applying recipes to roles
          5. Mapping your roles to nodes
          6. Converging a node
          7. Environments
        3. Organizing your configuration data
          1. Example attribute data
          2. Data bags
            1. Knowing when to use data bags
        4. Large-scale infrastructure
        5. Summary
      3. 3. Integrating with the Cloud
        1. Leveraging the cloud
          1. Amazon EC2
            1. Installing the EC2 knife plugin
            2. Setting up EC2 authentication
            3. Provisioning an instance
            4. Bootstrapping the instance
            5. Terminating the instance
            6. Removing the Chef node
          2. Rackspace Cloud
            1. Provisioning an instance
            2. Terminating an instance
            3. Removing the Chef node
        2. Summary
      4. 4. Working with Cookbooks
        1. Attributes
          1. Multiple attribute files
            1. Supporting multiple platforms
            2. Loading external attributes
          2. Using attributes
        2. Metadata
        3. Recipes
        4. Resources
          1. Using resources
          2. Overriding a default behavior
        5. Templates
          1. Why use templates?
            1. A quick ERB primer
              1. Executing Ruby
                1. Variable replacement
          2. The template resource
          3. The template variables
            1. Passing variables to a template
            2. Accessing computed configurations
          4. Searching for templates
        6. Definitions
        7. Recipes
          1. Developing recipes
        8. Writing recipes
          1. Starting out small
          2. Installing a simple service
          3. Getting more advanced
        9. Summary
      5. 5. Testing Your Recipes
        1. Testing recipes
        2. RSpec
        3. RSpec and ChefSpec
          1. Testing basics
          2. Comparing RSpec with other testing libraries
          3. Using ChefSpec
        4. Getting started with ChefSpec
          1. Installing ChefSpec
          2. Locking your dependencies in Ruby
          3. Creating a simple recipe and a matching ChefSpec test
            1. Writing a ChefSpec test
            2. Building your recipe
            3. Executing tests
            4. Understanding failures
          4. Expanding your tests
            1. Multiple examples in a spec test
            2. Testing for multiple platforms
        5. Summary
      6. 6. From Development to Deployment
        1. Describing the setup
        2. Deploying software with Chef
        3. Configuring your local environment
        4. Modeling a simple Python application
        5. Managing the cookbooks
          1. Downloading cookbooks
          2. Looking at the database recipe
          3. Looking at your application deployment cookbook
          4. Preparing the directories
          5. Constructing your Python virtual environment
          6. Checking the source code
          7. Installing any extra dependencies
            1. Managing dependencies in Chef
            2. Managing dependencies elsewhere
          8. Using Python's requirements file
          9. Configuring your application
          10. Keeping your application running
        6. Defining roles
          1. Creating the base server role
          2. Creating the database server role
          3. Creating the web server role
        7. Adding users
        8. Provisioning EC2 instances
          1. Configuring the database host
        9. Configuring the web server
        10. Deploying your software
          1. Manually deploying updates
          2. Automating deployment
        11. Summary
      7. 7. Beyond Basic Recipes and Cookbooks
        1. Managing users
          1. Evolution of a shell user recipe
          2. Storing data in data bags
            1. Creating a data bag for users
            2. Searching for data
          3. Searching inside recipes
          4. Enhancing your user cookbook
          5. Distributing SSH keys
            1. Templating the authorized keys
            2. Adding deployment keys
        2. Writing custom extensions
          1. Developing a custom definition
            1. Organizing your code
            2. Writing a definition for using PIP
            3. Defining a full application template
          2. Building a resource
            1. Defining the resource
            2. Implementing the provider
            3. Modifying resources
            4. Loading an existing resource
            5. Declaring that a resource was updated
        3. Working with data bags
          1. Securing your data bags
            1. Secret keys
            2. Encrypting your data
            3. Decrypting your data
            4. Storing keys on nodes
          2. Searching your data
            1. Searching your data bags with knife
            2. Searching your data bags from a recipe
            3. Querying your data
          3. Managing multiple machines with search queries
        4. Summary
      8. 8. Extras You Need to Know
        1. Vagrant and Chef-solo
          1. Installing Vagrant
          2. Provisioning a new host with Vagrant
          3. Booting your Vagrant image
          4. Combining Vagrant with Chef-solo
            1. Understanding the limitations of Chef-solo
            2. Configuring Chef-solo
            3. Telling Chef-solo what to run
            4. Using roles and data bags with Chef-solo
              1. Injecting custom JSON data
              2. Providing a custom node name
        2. Getting to know the Chef shell
          1. Using the Chef shell
            1. The standalone mode
            2. The solo mode
            3. The client mode
          2. Interacting with the Chef server using the shell
            1. Interacting with data
            2. Searching your data
            3. Editing your data
            4. Transforming data
          3. Executing recipes with Chef shell
            1. Creating a recipe in the shell
            2. Defining node attributes
              1. Setting attributes
              2. Accessing attributes
            3. Using configuration blocks
            4. Interactively executing recipes
          4. Debugging with the Chef shell
            1. Using the breakpoint resource
        3. Integration testing
          1. Using Test Kitchen
            1. Installing Test Kitchen
            2. Testing with Test Kitchen
              1. Building a simple cookbook
              2. Preparing your cookbook for the kitchen
              3. Testing your new cookbook
                1. Provisioning the instance
                2. Converging the newly created instance
                3. Writing a simple test
                4. Combining all the steps
        4. Extending Chef
          1. Writing an Ohai plugin
            1. A note about writing Ohai plugins
          2. Chef with Capistrano
        5. Automation and integration
          1. Automated updates and deployments
        6. Summary
    7. 2. Module 2
      1. 1. Chef Infrastructure
        1. Introduction
        2. Using version control
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Installing the Chef development kit on your workstation
          1. How to do it...
          2. How it works...
          3. See also
        4. Using the hosted Chef platform
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Managing virtual machines with Vagrant
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Creating and using cookbooks
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Inspecting files on your Chef server with knife
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Defining cookbook dependencies
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        9. Managing cookbook dependencies with Berkshelf
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        10. Downloading and integrating cookbooks as vendor branches into your Git repository
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        11. Using custom knife plugins
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        12. Deleting a node from the Chef server
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        13. Developing recipes with local mode
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Running knife in local mode
            2. Moving to hosted Chef or your own Chef server
          5. See also
        14. Using roles
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        15. Using environments
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        16. Freezing cookbooks
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        17. Running Chef client as a daemon
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        18. Using chef-shell
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      2. 2. Evaluating and Troubleshooting Cookbooks and Chef Runs
        1. Introduction
        2. Testing your Chef cookbooks
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Flagging problems in your Chef cookbooks
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Test-driven development for cookbooks using ChefSpec
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Integration testing your Chef cookbooks with Test Kitchen
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Showing affected nodes before uploading cookbooks
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Overriding a node's run list to execute a single recipe
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        8. Using why-run mode to find out what a recipe might do
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        9. Debugging Chef client runs
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        10. Inspecting the results of your last Chef run
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        11. Raising and logging exceptions in recipes
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        12. Diff-ing cookbooks with knife
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        13. Using community exception and report handlers
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        14. Creating custom handlers
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      3. 3. Chef Language and Style
        1. Introduction
        2. Using community Chef style
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Using attributes to dynamically configure recipes
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Calculating values in the attribute files
          5. See also
        4. Using templates
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Mixing plain Ruby with Chef DSL
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Installing Ruby gems and using them in recipes
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Using libraries
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Using definitions
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        9. Creating your own Lightweight Resource Providers (LWRP)
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        10. Extending community cookbooks by using application wrapper cookbooks
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        11. Creating custom Ohai plugins
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        12. Creating custom knife plugins
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      4. 4. Writing Better Cookbooks
        1. Introduction
        2. Setting the environment variables
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Passing arguments to shell commands
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Overriding attributes
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Using search to find nodes
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Using knife to search for nodes
            2. Searching for arbitrary node attributes
            3. Using Boolean operators in search
          5. See also
        6. Using data bags
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Using search to find data bag items
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Using encrypted data bag items
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Using a private key file
          5. See also
        9. Accessing data bag values from external scripts
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        10. Getting information about the environment
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        11. Writing cross-platform cookbooks
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Avoiding case statements to set values based on the platform
            2. Declaring support for specific operating systems in your cookbook's metadata
          5. See also
        12. Finding the complete list of operating systems you can use in cookbooks
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        13. Making recipes idempotent by using conditional execution
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      5. 5. Working with Files and Packages
        1. Introduction
        2. Creating configuration files using templates
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Using pure Ruby in templates for conditionals and iterations
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Installing packages from a third-party repository
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Installing software from source
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Running a command when a file is updated
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Distributing directory trees
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Cleaning up old files
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        9. Distributing different files based on the target platform
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
      6. 6. Users and Applications
        1. Introduction
        2. Creating users from data bags
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Securing the Secure Shell Daemon (SSHD)
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Enabling passwordless sudo
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Managing NTP
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Managing nginx
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Creating nginx virtual hosts
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Creating MySQL databases and users
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        9. Managing WordPress sites
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        10. Managing Ruby on Rails applications
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        11. Managing Varnish
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        12. Managing your local workstation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      7. 7. Servers and Cloud Infrastructure
        1. Introduction
        2. Creating your infrastructure using Chef Provisioning
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Creating cookbooks from a running system with Blueprint
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Running the same command on many machines at once
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
        5. Setting up SNMP for external monitoring services
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Deploying a Nagios monitoring server
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Building high-availability services using heartbeat
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Using HAProxy to load-balance multiple web servers
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        9. Using custom bootstrap scripts
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        10. Managing firewalls with iptables
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        11. Managing fail2ban to ban malicious IP addresses
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        12. Managing Amazon EC2 instances
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        13. Loading your Chef infrastructure from a file with spiceweasel and knife
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
    8. 3. Module 3
      1. 1. Setting Up a Development Environment on Your Workstation
        1. Re-introducing Chef
          1. What version of the Chef tools do I use?
          2. References
        2. Filling in the gaps in your Chef knowledge base
          1. Major pieces of a Chef puzzle
          2. The Chef client
          3. The Ohai Chef tool
          4. Recipes and cookbooks
          5. Chef run lists
          6. Chef roles
          7. Chef resources
          8. More things to consider
          9. Data bags
          10. Environments
          11. The Chef supermarket
          12. Chef Development Kit
          13. Setting up an on-premise (private) Chef Server
          14. References
        3. Exploring the Chef Development Kit
          1. The Chef Knife
          2. Community tools
          3. References
        4. Installing Chef Development Kit
          1. Downloading ChefDK
          2. Installing ChefDK
          3. Verifying ChefDK
          4. References
        5. Setting up a standard Chef repo
          1. Using the Chef tool for Chef repo
          2. The repo starter kit
          3. Files for your .chef folder – a safer way
          4. Growing your own tree
          5. Self-signed certificates
          6. References
        6. What else do you need?
          1. Using your favorite editor
          2. Version control systems
          3. Virtualization hypervisor
          4. Vagrant
          5. References
        7. What is chef-apply?
          1. Why is that useful?
          2. References
        8. Summary
      2. 2. Knife Tooling and Plugins
        1. Knife help
          1. References
        2. Knife subcommands
          1. Knife Bootstrap
          2. Knife Node
          3. Knife Diff
          4. Knife Exec
          5. Knife SSH
          6. Knife Search
          7. References
        3. Knife to editor integration
          1. Using the "wait" option
          2. Does my editor require the wait option?
          3. References
        4. Knife Windows plugin
          1. Installing the Knife Windows plugin
          2. Bootstrapping a Windows node
          3. Searching for Windows node data
          4. References
        5. Knife EC2 plugin
          1. Installing the Knife EC2 plugin
          2. Creating an EC2 instance
          3. Bootstrapping an existing EC2 instance
          4. Deleting EC2 instances
          5. References
        6. Creating new Knife plugins
          1. The basic plugin file format
          2. Example – A simpler EC2 Create Server plugin
          3. References
        7. Summary
      3. 3. Leveraging Roles, Environments, and Policies
        1. Using Chef roles
          1. How to create a role
          2. Using per-environment run-lists in roles
          3. Using nested roles
          4. There is a downside to roles
          5. References
        2. Using Chef environments
          1. The _default environment
          2. Creating environments
          3. Specifying cookbook versions in environments
          4. References
        3. Using Chef organizations
          1. Creating organizations
          2. Access control
          3. References
        4. Learning the attribute precedence hierarchy
          1. Understanding attribute precedence factors
          2. Resulting precedence hierarchy
        5. Exploring policies
          1. What exactly is a policy?
          2. Why would I use a policy?
          3. How do I use a policy?
          4. Another example
          5. How to specify the source options for cookbooks
          6. What are the "Gotchas"?
          7. References
        6. Summary
      4. 4. Custom Resources
        1. Out with the old (LWRPs), in with the new (Custom Resources)
          1. What is the difference between the old way and the new way of defining resources?
          2. What is a Custom Resource?
          3. References
        2. Creating an example use case
          1. What is the goal?
          2. Creating the cookbook
          3. Creating the default recipe
          4. The recipe worked, but what is missing?
          5. References
        3. Creating and using a Custom Resource
          1. What makes up a Custom Resource?
          2. Creating the "website" Custom Resource
          3. Using our Custom Resource
          4. References
        4. Making a Custom Resource more reusable
          1. Making a Custom Resource-only cookbook
          2. Reuse the code from the "mywebapp" example
          3. Using the reusable Custom Resource-only cookbook
          4. Handling idempotence
          5. References
        5. Subclassing a Custom Resource
          1. Convert our resource into a library module
          2. Subclassing the library module Custom Resource
          3. References
        6. Summary
      5. 5. Provisioning in the Traditional Data Center
        1. VMware provisioning
          1. Installing the knife-vsphere plugin
          2. Provisioning VMs using the knife-vsphere plugin
          3. Cleaning up our vSphere and Chef environments
          4. Using Chef with VMware and Vagrant
          5. References
        2. OpenStack provisioning
          1. Setting up a DevStack OpenStack all-in-one environment
          2. Deploying the DevStack Host VM
          3. Downloading and installing DevStack
          4. Downloading the demo project rc file and applying it
          5. Adding the security rules to allow ping and ssh traffic
          6. Installing the knife OpenStack plugin
          7. Setting up the DevStack public key
          8. Allocating some floating IP addresses to the project
          9. Configuring the knife-openstack plugin knife settings
          10. Adding a CentOS instance image to provision
          11. Provisioning a new instance
          12. References
        3. Network automation
          1. Automating juniper devices
          2. Automating Cisco systems
          3. Automating F5 LTMs
          4. References
        4. Summary
      6. 6. Provisioning in the Cloud
        1. Provisioning AWS EC2 instances
          1. Understanding EC2 authentication
          2. Creating key pairs
          3. Creating security groups
          4. Installing Chef Server into an EC2 instance
          5. References
        2. Provisioning Microsoft Azure instances
          1. Installing the knife-azure plugin
          2. Configuring the plugin
          3. Verifying the configuration
          4. Generating public/private key pairs
          5. Provisioning virtual machines
          6. Provisioning a new Chef server into Azure
          7. References
        3. Provisioning in the Google Cloud platform
          1. Installing and configuring the knife-google plugin
          2. Creating and registering your key pairs
          3. Provisioning virtual machines with the GCE
          4. Deploying Chef server into a GCE instance
          5. References
        4. Looking at an honorable mention – Linode
          1. References
        5. Provisioning containers in Docker
          1. Setting up a Docker server to host our containers
          2. Installing and using Docker on our Chef Workstation
          3. Using the knife-docker plugin
          4. References
        6. Summary
      7. 7. Test-Driven Development
        1. Analyzing cookbooks with RuboCop
          1. Using RuboCop
          2. Examining the RuboCop output
          3. Customizing RuboCop
          4. References
        2. Analyzing cookbooks with Foodcritic
          1. Using Foodcritic
          2. Examining the Foodcritic output
          3. Customizing Foodcritic
          4. References
        3. Unit testing with ChefSpec
          1. Using ChefSpec
          2. Expanding our tests
          3. References
        4. Integration testing with Kitchen and ServerSpec
          1. Preparing our tests
          2. Kitchen create
          3. Kitchen converge
          4. Kitchen verify
          5. References
        5. Summary
      8. 8. Using Chef Provisioning
        1. What is Chef provisioning?
          1. It's highly idempotent
          2. A hypothetical example
          3. References
        2. How to use Chef Provisioning
          1. Chef Provisioning resources
          2. A Vagrant example
          3. A cloud example with AWS
          4. A Docker example
          5. References
        3. Summary
      9. A. Bibliography
    9. Index