Test-Driven Infrastructure with Chef
Bring behaviour-driven development to infrastructure as code
Publisher: O'Reilly Media
Final Release Date: June 2011
Pages: 90

Test-Driven Infrastructure with Chef demonstrates a radical approach to developing web infrastructure that combines the powerful Chef configuration management framework with Cucumber, the leading Behavior-driven development (BDD) tool. Learn how to deliver real business value by developing infrastructure code test-first.

Infrastructure consultant Stephen Nelson-Smith shows you how this unique approach allows you to make significant changes without the fear of unexpected side effects—a great benefit when you’re developing code to control your production infrastructures. By using the test-first approach introduced in this book, you gain increased security, code quality, and peace of mind.

  • Learn the core principles behind the infrastructure-as-code approach, including modularity, cooperation, extensibility, and flexibility
  • Take a high-level tour of the Chef framework, tool, and API, as well as the community behind the project
  • Set up a workstation to interact with the Chef API
  • Get an overview of Cucumber and learn the principles of BDD
  • Start using Cucumber-Chef, the open source infrastructure testing platform
  • Explore test-driven infrastructure development with a hands-on tutorial
Table of Contents
Product Details
About the Author
Colophon
Recommended for You
Customer Reviews

REVIEW SNAPSHOT®

by PowerReviews
O'Reilly MediaTest-Driven Infrastructure with Chef
 
3.6

(based on 9 reviews)

Ratings Distribution

  • 5 Stars

     

    (2)

  • 4 Stars

     

    (4)

  • 3 Stars

     

    (0)

  • 2 Stars

     

    (3)

  • 1 Stars

     

    (0)

67%

of respondents would recommend this to a friend.

Pros

  • Easy to understand (7)
  • Concise (5)
  • Helpful examples (4)
  • Well-written (4)
  • Accurate (3)

Cons

  • Not comprehensive enough (6)
  • Too basic (4)
  • Too many errors (3)

Best Uses

  • Intermediate (6)
  • Novice (4)
    • Reviewer Profile:
    • Developer (7), Sys admin (7)

Reviewed by 9 customers

Sort by

Displaying reviews 1-9

Back to top

 
5.0

Essential Reading for Devops

By aob

from Texas

About Me Sys Admin

Verified Reviewer

Pros

  • Accurate
  • Easy to understand
  • Well-written

Cons

  • Not comprehensive enough
  • Too many errors

Best Uses

  • Intermediate
  • Novice
  • Student

Comments about O'Reilly Media Test-Driven Infrastructure with Chef:

I heard about this book on IRC, and thought I'd give it a try. I was
intrigued by the mixed reviews, especially as on the O'Reilly site the
book was well-received. The author is well-known in the Chef
community as a consultant and trainer, so I was interested to see what
he had to say on the subject.

Firstly, let me put some misconceptions to rest:

- This book is not fundamentally a Chef book, it's an exploration of the idea of applying test-driven development to infrastructure as code. It uses Chef as the framework for doing this.
- This book is not expensive - I think I paid $10 for my copy, which I think is good value

The first chapter presents an introduction to the idea of
infrastructure as code - it looks the origins of the movement, its
core principles, and the talks about some of the risks. The basic
argument seems to be that if we're going to practice infrastructure as
code, we need to take it seriously as a software project and apply
some well-known best practices from the software devlopment world. I
thought this was as good an introduction to the subject as I've found
anywhere on the web, and found the argument persuasive.

The second chapter presents a very high-level introduction to
Chef. It's only a few pages long, but I felt it managed to encapsulate
the fundamentals of the tool in a way which the Opscode website, wiki
and documentation site didn't achieve. I was particularly impressed
that in a book written two years ago, this hasn't aged at all. I
would recommend this chapter as a quick introduction to Chef.

The third chapter is designed to get the user up and running with
Chef. It covers installing Ruby (using RVM), getting set up with
Opscode's Hosted Chef platform, and getting your workstation ready to
start writing infrastructure code. This chapter seems to get crucified
by the negative reviewers, but I don't understand why. At the time it
was written, there was no easy way to install Chef, and electing to
use the hosted platform makes perfect sense for an instructional book
which wants to focus on the ideology of test-driven infrastructure. I
learned some neat tips on Git, and found the discussion of the
chef-repo to be informative. Sure, it's not so useful now we have
Omnibus installers, which ship Ruby as part of the install, but I
think the chapter was fine.

The fourth chapter was an introduction to the ideas of Behavior-driven
Development. I come from a system administration background, so this
was interesting and new content for me. It provided useful historical
background, and explained clearly and succintly the ideas of TDD and
BDD, and why they mattter. Again, I think this is one of the best
introductions to the subject I've ever read. It taught me useful
concepts and prepared the groundwork for the subsequent chapters. I
really enjoyed this section.

The fifth chapter introduced a tool called cucumber-chef. As in the
previous chapters it took a patient approach to explaining the ideas
and benefits, before taking me through how to use it. Again, I found
a few real gems in here, such as a great tip on making my knife config
work with multiple organizations. It contained a walkthrough of
signing up for AWS, which perhaps isn't needed, but again, two years
ago, AWS wasn't so well-known, and the walk through only takes up two
pages. Even then, I found I learned something about knife,

The final chapter is a bit of a mixed bag, but I think this is mainly
because the version of cucumber-chef that it uses is (obviously) two
years old. Anyone expecting this to be 100% accurate is simply naive,
in my view. So, although I found the worked example hard to follow,
the actual content and the basic ideas were excellent. I loved the
way it covered requirements gathering, and then talked through the
red-green-refactor approach to converting those requirements into
working infrastructure. This chapter also contained a more detailed
introduction to Chef, covering resources, recipes, cookbooks and
roles. I thought this was very clear and again, despite being based
on version 10, wasn't at all out of date. It also did an excellent
job of explaining what actually happens when Chef runs. It gives an
example of using so-called databags to contain user information and
ssh keys, and also explains how Chef templates work. There was a
section on Chef enviroments too. Given that this is a book about
testing, the author managed to fit a lot of really valuable Chef
instruction into this chapter, all of which is accurate and helpful.

I felt the chapter finished in a bit of a hurry - I would have liked
to have seen more about using a bootstrap or a knife command to build
a machine, but this wasn't really necessary for the argument of the
book, so it didn't spoil it for me in any way.

The final chapter - next steps - was a discussion starter - it gave me
some good ideas, and made me wish for more. It talks about the
importance of continuous integration and how the tests we write could
form the basis of a monitoring solution. I thought these were good
ideas - I only wished the author had covered them in the book.

In conclusion I thought this was an excellent book, and is required
reading for anyone interested in DevOps. There are flaws, the editing
is sloppy in places, and the actual worked example simply won't work,
but I was able to make it work on the new version of Cucumber-chef by
reading the documentation. For such a small title, the author manages
to cram in a massive amount of information and wisdom - I felt I
learned a huge amount, and got way more value from it than the $10 I
spent.

Don't be swayed by the poor reviews - this book is really great. I
hear the 2nd edition will be out very soon, and I can't wait to see
what that includes.

Summary: Essential reading for Devops.

 
5.0

Good tutorial about the best practice

By Anton Baranov

from Irkutsk, Russia

About Me Sys Admin

Verified Reviewer

Pros

  • Easy to understand
  • Helpful examples
  • Well-written

Cons

  • Too basic

Best Uses

  • Novice

Comments about O'Reilly Media Test-Driven Infrastructure with Chef:

Good tutorial for beginners. Book describes all tools, which could be need for working with chef.
Good describing of "infrasctructure as a code" - this book describes fundamental practices, which very useful for maintenance large infrastructures.

(1 of 2 customers found this review helpful)

 
2.0

This isn't an introduction to Chef

By Schuyler

from San Francisco, CA

About Me Developer, Sys Admin

Pros

  • Concise

Cons

  • Difficult to understand
  • Not comprehensive enough
  • Too basic

Best Uses

    Comments about O'Reilly Media Test-Driven Infrastructure with Chef:

    I was hoping for a solid introduction to Chef, and this isn't it. The Chef material is cursory at best, and not very clearly written. Mostly the book is about Cucumber, which is a very interesting technology but not what I was after. Finally, at a mere 90 pages, this book is *way* too expensive for what it is. Wish I could get my money back.

    (1 of 1 customers found this review helpful)

     
    4.0

    Great, no-nonsense introduction to Chef

    By sl4mmy

    from Chicago, IL

    About Me Developer

    Verified Reviewer

    Pros

    • Concise
    • Easy to understand
    • Well-written

    Cons

    • Not comprehensive enough

    Best Uses

    • Intermediate
    • Novice

    Comments about O'Reilly Media Test-Driven Infrastructure with Chef:

    I thought this book was fantastic! It offers a great, no-nonsense introduction to Chef and the concept "Infrastructure as Code."

    I poked around the Chef wiki before reading this book, but I couldn't find a good, concise introduction to the framework. I understand the concepts of nodes, roles, resources, recipes, cookbooks, but I was missing a guide that would tie it all together for me. Turns out, this book is that guide! And it also introduces the cucumber-chef tool and shows how to build recipes and cookbooks test-first.

    The book introduces "Infrastructure as Code," test-driven development, Chef, and cucumber-chef, and then proceeds to a simple example using Chef to provision a shared Linux server. The recipes for the server are developed test-first, demonstrating both the technique and the workflow.

    Overall, this book is the best introduction to Chef I've come across, and after reading it I feel confident in my ability to start writing my own recipes test first.

    The biggest drawback of the book is that is short. Although it covers a great deal of material in so few pages, I would have liked a few more chapters at the end that explored more advanced topics, or dug into some of the other topics in more detail. As it is, I can't wait to get my hands on a copy of the author's next book, "Chef: The Definitive Guide" (perhaps that was his intent all along! ;P).

    (5 of 5 customers found this review helpful)

     
    2.0

    Good Concept; Short on Examples

    By Jason Wadsworth

    from Cambridge, MA

    About Me Developer, Sys Admin

    Verified Reviewer

    Pros

    • Interesting Concept
    • Thought-Provoking

    Cons

    • Not comprehensive enough
    • Too many errors

    Best Uses

    • Intermediate

    Comments about O'Reilly Media Test-Driven Infrastructure with Chef:

    Summary

    Test-Driven Infrastructure with Chef describes a rationale and an approach to developing automated tests for system infrastructure. It includes an explanation of behavior-driven development, and detailed instructions for setting up a testing system using cucumber-chef on EC2.

    Audience

    Surprisingly little time was spent talking about cucumber-chef and how to use it. The majority of the book is spent explaining BDD and why you'd want to apply it to infrastructure, and then explaining in minute detail the process to get RVM, EC2 and Chef configured. The last portion of the book covered the process of using cucumber-chef to set up a server with multiple user accounts.

    Being already familiar with the supporting tools, I found this disappointing. The teamserver example was too simple and unrealistic. It would have been more useful to see some examples using cucumber-chef for a more realistic use-case, such as setting up a web server.

    Unfortunately, I suspect the text isn't likely to be helpful to a reader who isn't familiar with the tools either. The instructions were already outdated when I read them, shortly after the book was released. A reader who is new to Cucumber, Chef, Ruby or EC2 will be in danger of getting lost before they even get to the point where they can run a test against an instance.

    Practicality

    In the course of working through the examples, I was continually frustrated by the amount of time it took to get feedback. The tests are really slow. It's hard to imagine actually developing red/green/refactor-style at this pace. I like the concept of being able to test the infrastructure, but it doesn't seem practical with these tools.

    I'm not convinced that it would really be worth the time involved to write tests at this level anyway. Writing integration tests against the full application stack might be a better use of your testing time. The true test of the infrastructure is how well it supports needs of the application and it's users.

    Neither BDD-style infrastructure tests nor full-stack integration tests will help you with the most difficult and interesting infrastructure challenges: scaling and stability. Simulating all the wonderful ways that a server can crash (used up disk space, hung connections, etc.) would be a complex, difficult, slow, and inevitably incomplete endeavor. It's possible that server ops really is fundamentally different than application development.

    Bottom Line

    - Good explanation of BDD and how it could be applied to infrastructure
    - Short on useful examples for readers familiar with the supporting tools
    - Thorough instructions for setting up EC2, Chef and RVM, but likely to have a short shelf-life

    [This review was written as part of the O'Reilly Blogger Review Program.]

    (3 of 3 customers found this review helpful)

     
    2.0

    Good Overview but Poor Walkthrough

    By Robby Grossman

    from Cambridge, MA

    About Me Developer, Sys Admin

    Pros

    • Easy to understand

    Cons

    • Not comprehensive enough
    • Too basic
    • Too many errors

    Best Uses

    • Intermediate

    Comments about O'Reilly Media Test-Driven Infrastructure with Chef:

    I was intrigued by the idea of test-driven infrastructure development, and since we will be using Chef I thought this book would be a great place to start.

    The book takes great care to walk the user through the various processes of installing Ruby, configuring Git, setting up AWS, etc. If you're familiar with these things, you can skip the first 40 pages. I think the author should removing these sections and considering them prerequisite knowledge because as I'll explain next, it is too much to cover in an 80-page book.

    The author's workaround for dealing with AWS novices is a 20-step walkthrough of setting up an account via the AWS Management Console. I appreciate the attempted thoroughness but the end result is a very verbose how-to guide that will be outdated as soon as Amazon pushes a single UI update. If I were completely new to AWS and got lost at step 14, that would make for a very frustrating experience. If you're playing with chef and cucumber in the cloud, I think it's reasonable to expect a working knowledge of Ruby and AWS.

    I also found the cucumber- and chef-specific examples to be poorly edited. One displayed set of tests contained the same test twice and omitted another. Later, we are asked to run the test suite before setting an AWS operating system image in knife.rb, a step which is required but not discussed. I was able to debug my way through these things because I have some experience with these tools. But if you are as new to these tools as the book assumes you are, you may quickly find yourself frustrated.

    The book succeeds in providing a high level overview of how you might test your chef recipes using cucumber, but fails as a walkthrough for getting you started. This book can provide value to intermediate chef developers who are curious how TDD might work for them. It is too broken for beginners, and too basic for anybody bordering on expert.

    (1 of 1 customers found this review helpful)

     
    4.0

    A solid overview to TDD infrastructure

    By Aaron Sumner

    from Lawrence KS

    About Me Designer, Developer, Educator, Maker, Sys Admin

    Verified Reviewer

    Pros

    • Concise
    • Easy to understand
    • Helpful examples

    Cons

      Best Uses

      • Expert
      • Intermediate

      Comments about O'Reilly Media Test-Driven Infrastructure with Chef:

      Virtualization has made it incredibly easy for web software developers to quickly and relatively cheaply scale their products, but what happens when a virtual infrastructure becomes too much to manage? Enter virtualization management tools like the popular, open source Chef, which makes deploying services as simple as editing configuration files. And if you want to rest assured that your deployments will work as planned, you'd be well-served to leverage one of the many test-driven development frameworks available for Ruby. In Test-Driven Development with Chef, author Stephen Nelson-Smith shows how to leverage Cucumber to do just this, using the cucumber-chef gem.

      Test-Driven Infrastructure with Chef is a short, relatively quick read—the print version checks in at 88 pages. The majority of the book presents the task of test-driven infrastructure deployment via a basic example that mirrors real-world needs—in this case, allowing developers to connect to a server, via SSH, using a private key mechanism. Each step of the example is well-explained and easy to follow. With that said, though, it's worth noting that it's probably not well-suited for a general reference for Chef. In fact, the author has a more authoritative book on the topic coming out sometime in the future. If you're already familiar with Chef, though, and want to learn more about using TDD to make your deployments more rock-solid, this may not be an issue.

      Overall, I found Test-Driven Infrastructure with Chef to be a solid overview of the concepts presented. While it may not be the end-to-end reference on using TDD to drive software-based infrastructure projects, it's a good orientation to the concepts and potential issues involved with using Chef and Cucumber in deploying your next virtual server.

      Note: I wrote this review for O'Reilly's Blogger Review Program.

      (1 of 1 customers found this review helpful)

       
      4.0

      Start Doing Test-Driven Infrastructure

      By Rob

      from Brisbane, Australia

      About Me Developer

      Verified Reviewer

      Pros

      • Accurate
      • Concise
      • Easy to understand
      • Helpful examples

      Cons

        Best Uses

        • Intermediate

        Comments about O'Reilly Media Test-Driven Infrastructure with Chef:

        Test-Driven Infrastructure with Chef is a good little book. I grabbed a copy, having heard much about Chef http://www.opscode.com/chef/, and Puppet http://www.puppetlabs.com/, tools for automating machine and systems integration. The book did a good idea of introducing many of the foundational ideas and concepts behind devops, automating infrastructure deployment, chef, TDD, BDD, and test driving infrastructure. The key foundational information provides a good grounding for the book, and is one of the big reasons to read it. These foundations fill in any gaps in understanding, and provide a great basis for doing the test driven infrastructure development talked about in the book.

        The sections in the book showing actual test driven infrastructure ended up being quite short. If you've already up to speed with Chef but just want to skill up on TDI, then this might not be the book for you. If however, you're like me, and just starting the journey on OpsCode and chef, this book makes for great little read, and I'd recommend it to you.

        [This book was reviewed as a part of the O'Reilly Blogger Review Program]

        (2 of 2 customers found this review helpful)

         
        4.0

        Could have been so much more ..

        By Mike

        from San Francisco, CA

        About Me Developer, Sys Admin

        Verified Reviewer

        Pros

        • Accurate
        • Concise
        • Easy to understand
        • Helpful examples
        • Well-written

        Cons

        • Not comprehensive enough
        • Too basic

        Best Uses

        • Novice

        Comments about O'Reilly Media Test-Driven Infrastructure with Chef:

        This book is a great introduction to test driven development with Chef. Unfortunately the book is incredibly short and only has basic examples.

        Nonetheless, I would recommend it to anyone getting started with Chef. Right now there are no other books that cover Chef, let alone TDD/BDD with it.

        The book definitely left me wanting more.

        Displaying reviews 1-9

        Back to top

         
        Buy 2 Get 1 Free Free Shipping Guarantee
        Buying Options
        Immediate Access - Go Digital what's this?