Test-Driven Infrastructure with Chef, 2nd Edition

Book description

Since Test-Driven Infrastructure with Chef first appeared in mid-2011, infrastructure testing has begun to flourish in the web ops world. In this revised and expanded edition, author Stephen Nelson-Smith brings you up to date on this rapidly evolving discipline, including the philosophy driving it and a growing array of tools. You’ll get a hands-on introduction to the Chef framework, and a recommended toolchain and workflow for developing your own test-driven production infrastructure.

Several exercises and examples throughout the book help you gain experience with Chef and the entire infrastructure-testing ecosystem. Learn how this test-first approach provides increased security, code quality, and peace of mind.

  • Explore the underpinning philosophy that infrastructure can and should be treated as code
  • Become familiar with the MASCOT approach to test-driven infrastructure
  • Understand the basics of test-driven and behavior-driven development for managing change
  • Dive into Chef fundamentals by building an infrastructure with real examples
  • Discover how Chef works with tools such as Virtualbox and Vagrant
  • Get a deeper understanding of Chef by learning Ruby language basics
  • Learn the tools and workflow necessary to conduct unit, integration, and acceptance tests

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Conventions Used in This Book
    2. Safari® Books Online
    3. How to Contact Us
    4. Acknowledgments
  2. 1. The Philosophy of Test-Driven Infrastructure
    1. Underpinning Philosophy
    2. Infrastructure as Code
      1. The Origins of Infrastructure as Code
      2. The Principles of Infrastructure as Code
      3. The Risks of Infrastructure as Code
    3. Professionalism
  3. 2. An Introduction to Ruby
    1. What Is Ruby?
    2. Grammar and Vocabulary
      1. Methods and Objects
      2. Identifiers
        1. Variables
        2. Constants
        3. Keywords
        4. Method names
      3. More About Methods
      4. Classes
      5. Arrays
      6. Conditional logic
      7. Hashes
      8. Truthiness
      9. Operators
      10. Bundler
  4. 3. An Introduction to Chef
    1. Exercise 1: Install Chef
      1. Objectives
      2. Directions
      3. Worked Example
      4. Discussion
        1. The Chef framework
        2. The Chef tool
        3. The Chef API
        4. The Chef community
    2. Exercise 2: Install a User
      1. Objectives
      2. Directions
      3. Worked Example
      4. Discussion
    3. Exercise 3: Install an IRC Client
      1. Objectives
      2. Directions
      3. Worked Example
      4. Discussion
    4. Exercise 4: Install Git
      1. Objectives
      2. Directions
      3. Worked Example
      4. Discussion
  5. 4. Using Chef with Tools
    1. Exercise 1: Ruby
      1. Objectives
      2. Directions
      3. Worked Example
      4. Discussion
    2. Exercise 2: Virtualbox
      1. Objectives
      2. Directions
      3. Worked example
      4. Discussion
    3. Exercise 3: Vagrant
      1. Objectives
      2. Directions
      3. Worked Example
      4. Discussion
    4. Conclusion
  6. 5. An Introduction to Test- and Behavior-Driven Development
    1. The Principles of TDD and BDD
      1. A Very Brief History of Agile Software Development
      2. Test-Driven Development
      3. Behavior-Driven Development
        1. Building the right thing
        2. Reducing risk
        3. Evolving design
    2. TDD and BDD with Ruby
      1. Minitest: Unit Testing for the 21st Century
      2. RSpec: The Transition to BDD
      3. Cucumber: Acceptance Testing for the Masses
  7. 6. A Test-Driven Infrastructure Framework
    1. Test-Driven Infrastructure: A Conceptual Framework
      1. Test-Driven Infrastructure Should Be Mainstream
      2. Test-Driven Infrastructure Should Be Automated
      3. Test-Driven Infrastructure Should Be Side-Effect Aware
      4. Test-Driven Infrastructure Should Be Continuously Integrated
      5. Test-Driven Infrastructure Should Be Outside In
      6. Test-Driven Infrastructure Should Be Test-First
    2. The Pillars of Test-Driven Infrastructure
      1. Writing Tests
      2. Running Tests
      3. Provisioning Machines
      4. Feedback of Results
  8. 7. Test-Driven Infrastructure: A Recommended Toolchain
    1. Tool Selection
      1. Unit Testing
      2. Integration Testing
      3. Acceptance Testing
      4. Testing Workflow
    2. Supporting Tools: Berkshelf
      1. Overview
      2. Getting Started
      3. Example
        1. Berkshelf and Vagrant
        2. Berkshelf and Chef environments
      4. Advantages and Disadvantages
      5. Summary and Conclusion
    3. Supporting Tools: Test Kitchen
      1. Overview
      2. Getting Started
      3. Summary and Conclusion
    4. Acceptance Testing: Cucumber and Leibniz
      1. Overview
      2. Getting Started
      3. Example
      4. Advantages and Disadvantages
      5. Summary and Conclusion
    5. Integration Testing: Test Kitchen with Serverspec and Bats
      1. Introducing Bats
      2. Introducing Serverspec
      3. Templates
    6. Integration Testing: Minitest Handler
      1. Overview
      2. Getting Started
      3. Example
        1. Minitest Handler with Test Kitchen
      4. Advantages and Disadvantages
      5. Summary and Conclusion
    7. Unit Testing: Chefspec
      1. Overview
      2. Getting Started
      3. Example
      4. Advantages and Disadvantages
      5. Summary and Conclusion
    8. Static Analysis and Linting Tools
      1. Overview
      2. Getting Started
      3. Example
      4. Advantages and Disadvantages
      5. Summary and Conclusion
    9. To Conclude
  9. 8. Epilogue
  10. A. Bibliography
    1. Books on TDD and ATDD
    2. Books and Articles on BDD
    3. Books on Agile Testing in General
    4. Chef Articles and Presentations
    5. Books on Tools
    6. Books on Ruby
    7. Books on Bash and Shell Scripting
    8. General Programming Books
    9. Other Great Books
  11. Index
  12. About the Author
  13. Colophon
  14. Copyright

Product information

  • Title: Test-Driven Infrastructure with Chef, 2nd Edition
  • Author(s): Stephen Nelson-Smith
  • Release date: October 2013
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449372200