You are previewing Learning Chef.
O'Reilly logo
Learning Chef

Book Description

Automate your infrastructure using code and leverage DevOps with Chef

In Detail

Chef automation helps to transform infrastructure into simple code. This means that building, rebuilding, configuration, and scaling to meet your customer's needs is possible in just a few minutes in a real-time environment.

This book begins with the conceptual architecture of Chef, walking you through detailed descriptions of every Chef element. You will learn the procedure to set up your workstation and how to create a Cookbook in a hosted Chef environment.

Private Chef Server setup is covered in depth, with information on the necessity of on-premise Private Chef deployment, benefits, and installation and configuration procedures for the different types of Private Chef servers including standalone, tiered, and high-availability.

This book sheds light on industry best practices with practical Chef scenarios and examples.

What You Will Learn

  • Learn the basic fundamentals of automation and gain a detailed architectural understanding of each component of Chef

  • Install all the components of Chef, including troubleshooting instructions

  • Explore the intricacies of Cookbook writing and every component of a Cookbook

  • Work with the open source Chef server and learn about its installation on a virtual machine

  • Discover the Private Chef Server and its various types of installations

  • Familiarize yourself with the best practices while working with Chef, and the various consumer case studies of different types of Chef deployment for their infrastructure

  • 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 files e-mailed directly to you.

    Table of Contents

    1. Learning Chef
      1. Table of Contents
      2. Learning Chef
      3. Credits
      4. About the Authors
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
      8. 1. An Overview of Automation and Advent of Chef
        1. Automation
        2. Why automation is needed
        3. Introduction to Chef
          1. Why Chef is a preferred tool
          2. The salient features of Chef
          3. Automation with Chef
        4. Existing automation tools and comparison with Chef
          1. InstallShield
            1. Features of InstallShield
          2. AutoIt
            1. Features of AutoIt
          3. Windows PowerShell scripting
            1. Features of PowerShell
          4. CFEngine
            1. Features of CFEngine
          5. Puppet
          6. Bcfg2
          7. Cobbler
          8. Sprinkle
          9. cdist
          10. Pallet
          11. Rex
          12. Glu
          13. RunDeck
          14. Crowbar
          15. Fabric
          16. Ansible
          17. SaltStack
          18. Mina
          19. Juju
          20. Comparison with other popular tools
            1. Chef versus Puppet
            2. Chef versus CFEngine
        5. Self-test questions
        6. Summary
      9. 2. Different Components of Chef's Anatomy
        1. The Chef automation
        2. The Chef framework
        3. Chef components
          1. The Chef server
            1. Different types of Chef servers
              1. Hosted Chef server
              2. Private Chef
              3. Open source Chef-sever
            2. Chef server tools
            3. Different types of Chef server tools
              1. erchef
              2. Nginx
              3. WebUI
              4. Message queues
              5. Search index
              6. PostgreSQL
              7. Bookshelf
              8. Cookbooks
                1. Recipes
                2. Attributes
                3. Versions
              9. Node objects
                1. Run-lists
                2. Attributes
              10. Policies
                1. Roles
                2. Data bags
                3. An environment
          2. Workstations
            1. Workstation tools
              1. Knife
              2. A Chef repository
                1. Authentication procedure between a workstation and Chef server
          3. Nodes
            1. Types of nodes
              1. Physical nodes
              2. Virtual nodes
              3. Cloud instances
            2. Tools of a node
              1. A Chef-client
              2. Ohai
        4. The Chef server API
        5. GitHub
        6. Chef-solo
        7. The Chef community
          1. Databases
          2. Web servers
          3. Process management
          4. Programing languages
          5. Monitoring
          6. Package management
          7. Virtualization and cloud
        8. Chef-run
        9. Integration of Chef with Vagrant
        10. A quick hands-on experience of a Hosted Chef server
        11. Self-test questions
        12. Summary
      10. 3. Workstation Setup and Cookbook Creation
        1. The VirtualBox installation
        2. The Vagrant installation
        3. The Git installation
        4. Installation and configuration of a workstation
        5. Workstation setup - creating a Chef repository
          1. Workstation setup using Git on Windows 8
          2. Workstation setup without Git on CentOS
            1. The Ruby installation and required settings
          3. Setting up the Chef repository and downloading cookbooks
        6. Launching a virtual machine with Vagrant and a workstation setup
        7. Creating and uploading a simple cookbook
          1. Uploading cookbooks
        8. Troubleshooting
          1. Error code – type 1
            1. Meaning
            2. Troubleshooting steps
          2. Error code – type 2
            1. Meaning
            2. Troubleshooting steps
          3. Error code – type 3
            1. Meaning
            2. Troubleshooting steps
          4. Error code – type 4
            1. Meaning
            2. Troubleshooting steps
          5. Error code – type 5
            1. Meaning
            2. Troubleshooting steps
          6. Error code – type 6
            1. Meaning
            2. Troubleshooting steps
          7. Error code – type 7
            1. Meaning
            2. Troubleshooting steps
        9. Self-test questions
        10. Summary
      11. 4. Learning about Cookbooks
        1. Cookbook types
          1. Application cookbooks
          2. Library cookbooks
          3. Wrapper cookbooks
        2. Components of a cookbook
        3. Attributes
        4. Definitions
          1. Syntax of a definition
          2. Example of a definition
        5. Files
          1. Syntax of a file
          2. Example of a file
        6. Libraries
          1. Syntax of a library
          2. Example of a library
        7. Resources and providers
        8. Syntax of resources
        9. Example of resources
        10. Templates
          1. Syntax of a template
          2. Example of a template
          3. An LWRP
          4. Components of an LWRP
        11. Metadata
          1. The metadata.rb file
          2. The Error message
        12. Self-test questions
        13. Summary
      12. 5. Managing the Nodes
        1. Adding and deleting a node
          1. Adding a new node
          2. Deletion of a node
          3. Editing a node
        2. Bootstrapping target nodes
          1. The Knife.bootstrap command
          2. The verification process for a node
        3. Introducing search
          1. Syntax of a search query
          2. Search by different options
            1. Search by node
            2. Search by node and environment
            3. Search for nested attributes
            4. Search for multiple attributes
            5. A partial search
        4. Introducing data bags
        5. Introducing handler
          1. Types of handlers
          2. Installation and configuration of a handler
            1. The manual installation
            2. Using chef_handler
          3. Writing a simple handler
          4. Open source handlers
        6. Self-test questions
        7. Summary
      13. 6. Working with an Open Source Chef Server
        1. System requirements
        2. Installing an open source Chef server
          1. FQDN and hostnames configuration
            1. Restarting the virtual machine
            2. Changing the hostname
        3. Installing an open source Chef server on a VMware Fusion virtual machine – Ubuntu 12.04
          1. VM machine settings
          2. Installing an open source Chef server on a VM machine
          3. Installing an open source Chef server on a VMware Workstation virtual machine – CentOS 6.x
          4. Installing an open source Chef server on Amazon Web Services ( AWS )
          5. Setting up the workstation
          6. System requirements
          7. Bootstrapping a node
            1. The Nodes tab
            2. The Clients tab
        4. Using community cookbooks
        5. Upgradation of the open source Chef server
          1. Existing requirements
          2. Accessing the Chef server 0.10.x
          3. Downloading data from the Chef server 0.10.x
          4. Accessing the Chef server 11.x
          5. Updating Chef-validator settings
          6. Verifying the admin public key
          7. Verification of user passwords
          8. Uploading data to the Chef server 11.x
            1. The last steps
        6. Self-test questions
        7. Summary
      14. 7. Working with the On-premises Chef Server Setup
        1. The on-premises Chef server
        2. Benefits of on-premises Chef
          1. Simple to scale
          2. Completely automotive solution
          3. Fast and easy configuration management
          4. Reduced complexity within infrastructure
          5. Improved data encryption policies
        3. Types of on-premises Chef installations
          1. Standalone on-premises Chef
          2. Tiered on-premises Chef
          3. High-availability on-premises Chef
        4. Downloading the installation package
        5. Prerequisites for the standalone on-premises Chef installation
          1. Firewall requirements
        6. Installing standalone on-premises Chef
          1. Installing the on-premises Chef package on CentOS and Red Hat
        7. Prerequisites for the tiered on-premises Chef installation
          1. Load balancer requirements
            1. Configuring api_fqdn
          2. Firewall requirements
            1. Ports for frontend servers
            2. Ports for backend servers
          3. Configuring the private-chef.rb file
            1. The required settings for the backend server
            2. The required settings for the frontend server
            3. Adding on-premises Chef packages to servers
        8. Installing tiered on-premises Chef
          1. Configuring Bootstrap and installing on-premises Chef
          2. Configuring the frontend server and installing on-premises Chef
            1. Installing on-premises Chef packages
        9. Prerequisites for the high-availability Chef installation
          1. Load balancer requirements
            1. Configuring api_fqdn
            2. Ports for frontend servers
            3. Ports for backend servers
          2. Configure the private-chef.rb file
            1. The required settings for the backend server with Bootstrapping
            2. The required settings for other backend servers
            3. The required changes for frontend entries
              1. Configuring api_fqdn
              2. Examples
              3. Adding on-premises Chef packages to servers
        10. Installing the high-availability Chef server
          1. Installing on-premises Chef on the backend server
            1. Installing DRBD on the backend servers
              1. The DRBD installation on CentOS and Red Hat
              2. The DRBD installation on Ubuntu
            2. The DRBD configuration on the backend Bootstrap server
            3. The DRBD configuration on the backend non-Bootstrap server
              1. Checking the filesystem for the DRBD server
          2. Configuring on-premises Chef on the Bootstrap backend server
          3. Configuring on-premises Chef on the non-Bootstrap backend server
          4. Configuring and installing on-premises Chef on the frontend servers
            1. Installing on-premises Chef packages
        11. Managing on-premises Chef
          1. Service commands
            1. Viewing Chef commands
            2. Uninstalling on-premises Chef
            3. View configuration
            4. Reconfiguring Chef
          2. Service subcommands
            1. The hup subcommand
            2. The int subcommand
            3. The kill subcommand
            4. The once subcommand
            5. The service-list subcommand
            6. The start subcommand
            7. The restart subcommand
            8. The stop subcommand
            9. The status subcommand
            10. The tail subcommand
            11. The term subcommand
            12. Log files
        12. Self-test questions
        13. Summary
      15. 8. Managing Chef on Cloud Infrastructure
        1. What is cloud computing?
        2. Why Chef with cloud infrastructure?
        3. AWS EC2 bootstrapping using Chef
          1. Preparing your workstation
          2. Installing the knife-ec2 plugin
          3. Configuring the AWS settings and the knife.rb file
            1. Configuring knife.rb with your AWS Cloud credentials
          4. Bootstrapping the EC2 instance
            1. Various
            2. The expected output
          5. Running the Chef-client on the new client node (cloud instance)
            1. Verification of the complete installation
          6. Managing recipes on the new client node
          7. Running the Chef-client as a daemon
        4. Rackspace Cloud server bootstrapping
          1. The prerequisite to work with Rackspace Cloud
          2. Installing plugins for knife-rackspace
          3. Preparing the workstation with Rackspace credentials
          4. Bootstrapping the Rackspace Cloud server with the Chef-client
            1. Deleting Rackspace servers
          5. The Knife-cloud plugin
        5. VMware and Chef
        6. Self-test questions
        7. Summary
      16. 9. Best Practices while Using Chef
        1. Chef anti-patterns and patterns
          1. A wrapper cookbook
          2. A default cookbook
        2. Testing cookbooks
          1. Types of cookbook tests
            1. Checking the syntax
            2. Integration testing
            3. Checking the result
            4. Checking the consistency
            5. Checking the performance
        3. Best practices for effective usage of Chef
          1. Planning in advance
          2. Designing a cookbook
          3. Using a private recipe
          4. Avoiding the use of one giant cookbook
          5. Avoid overloading of a Chef environment
        4. Self-test questions
        5. Summary
      17. 10. Case Studies on Different Chef Deployments
        1. Case studies of Hosted Chef deployments
          1. Admeld
            1. Challenges with the infrastructure of Admeld
            2. The solution with Hosted Chef
            3. The final outcome
          2. Fanhattan
            1. Challenges with the infrastructure of Fanhattan
            2. The solution with Hosted Chef
            3. The final outcome
          3. Zumba Fitness
            1. Challenges with the infrastructure of Zumba Fitness
            2. The solution with Hosted Chef
            3. The final outcome
          4. The Limelight video platform
            1. Challenges with the infrastructure of Limelight
            2. The solution with Hosted Chef
            3. The final outcome
          5. Imagination
            1. Challenges with the infrastructure of Imagination
            2. The solution with Hosted Chef
            3. The final outcome
          6. Getaroom
            1. Challenges with the infrastructure of Getaroom
            2. The solution with Hosted Chef
            3. The final outcome
        2. Case studies of Private Chef deployment
          1. Ancestry.com
            1. Challenges with the infrastructure of Ancestry.com
            2. The solution with Private Chef
            3. The final outcome
          2. Facebook
            1. Challenges with the infrastructure of Facebook
            2. The solution with Private Chef
            3. The final outcome
          3. DreamHost
            1. Challenges with the infrastructure of DreamHost
            2. The solution with Private Chef
            3. The final outcome
        3. Case studies of the open source Chef deployment
          1. SolutionSet
            1. Challenges with the infrastructure of SolutionSet
            2. The solution with open source Chef
            3. The final outcome
        4. Case studies of the Chef-solo deployment
          1. Wharton School - University of Pennsylvania
            1. Challenges with the infrastructure of Wharton School
            2. The solution with Chef-solo
            3. The final outcome
        5. Self-test questions
        6. Summary
      18. Index