You are previewing Chef Infrastructure Automation Cookbook.
O'Reilly logo
Chef Infrastructure Automation Cookbook

Book Description

For systems administrators and developers this book could revolutionize your cloud and server infrastructure through automation. Packed with real world situations and practical recipes, it’s a dazzling insight into Chef.

  • Configure, deploy, and scale your applications

  • Automate error prone and tedious manual tasks

  • Manage your servers on-site or in the cloud

  • Solve real world automation challenges with task-based recipes

  • The book is filled with working code and easy-to-follow, step-by-step instructions

  • In Detail

    Irrespective of whether you're a systems administrator or a developer, if you're sick and tired of repetitive manual work and not knowing whether you may dare to reboot your server, it's time for you to get your infrastructure automated.

    Chef Infrastructure Automation Cookbook has all the required recipes to configure, deploy, and scale your servers and applications, irrespective of whether you manage 5 servers, 5,000 servers, or 500,000 servers.

    Chef Infrastructure Automation Cookbook is a collection of easy-to-follow, step-by-step recipes showing you how to solve real-world automation challenges. Learn techniques from the pros and make sure you get your infrastructure automation project right the first time.

    Chef Infrastructure Automation Cookbook takes you on a journey through the many facets of Chef. It teaches you simple techniques as well as fully fledged real-world solutions. By looking at easily digestible examples, you'll be able to grasp the main concepts of Chef, which you'll need for automating your own infrastructure. Instead of wasting time trying to get existing community cookbooks running in your environment, you'll get ready made code examples to get you started.

    After describing how to use the basic Chef tools, the book shows you how to troubleshoot your work and explains the Chef language. Then, it shows you how to manage users, applications, and your whole cloud infrastructure. The book concludes by providing you additional, indispensable tools and giving you an in-depth look into the Chef ecosystem.

    Chef Infrastructure Automation Cookbook will help you learn the techniques of the pros by walking you through a host of step-by-step guides to solve real-world infrastructure automation challenges.

    Table of Contents

    1. Chef Infrastructure Automation Cookbook
      1. Table of Contents
      2. Chef Infrastructure Automation Cookbook
      3. Credits
      4. Foreword
      5. About the Author
      6. About the Reviewers
      7. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      8. 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
          4. Questions
      9. 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 Chef on your workstation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. 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. Changing organizations based on the current Git branch
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        13. 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
        14. Running Chef Solo
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        15. Using roles
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        16. Using environments
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        17. Freezing cookbooks
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        18. Running Chef Client as a daemon
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        19. Using the Chef console (Chef Shell)
          1. How to do it...
          2. How it works...
          3. There's more...
          4. See also
      10. 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 started...
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Integration testing your cookbooks with Test Kitchen
          1. Getting started
          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 results of your last ChefClient run
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. 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. Diffing 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
      11. 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 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 Light Weight 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
      12. 4. Writing Better Cookbooks
        1. Introduction
        2. Setting 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. Accessing encrypted data bag items from within recipes
            2. 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 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
      13. 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
      14. 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 sites
          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 workstation
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      15. 7. Servers and Cloud Infrastructure
        1. Introduction
        2. 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
        3. 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
        4. 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
        5. Deploying a Nagios monitoring server
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. 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
        7. Using HAProxy to load-balance multiple web servers
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        8. Using custom bootstrap scripts
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        9. Managing firewalls with iptables
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        10. 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
        11. Managing Amazon EC2 instances
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        12. 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
      16. Index