1. Trang chủ
  2. » Công Nghệ Thông Tin

test driven infrastructure with chef

88 308 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 88
Dung lượng 5,04 MB

Nội dung

www.it-ebooks.info www.it-ebooks.info Test-Driven Infrastructure with Chef www.it-ebooks.info www.it-ebooks.info Test-Driven Infrastructure with Chef Stephen Nelson-Smith Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo www.it-ebooks.info Test-Driven Infrastructure with Chef by Stephen Nelson-Smith Copyright © 2011 Atalanta Systems LTD. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com. Editors: Mike Loukides and Meghan Blanchette Production Editor: Kristen Borg Proofreader: O’Reilly Production Services Cover Designer: Karen Montgomery Interior Designer: David Futato Printing History: June 2011: First Edition. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Test-Driven Infrastructure with Chef, the image of edible-nest swiftlets, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information con- tained herein. ISBN: 978-1-449-30481-2 [LSI] 1307648888 www.it-ebooks.info Table of Contents Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii 1. Infrastructure As Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 The Origins of Infrastructure as Code 2 The Principles of Infrastructure as Code 4 The Risks of Infrastructure as Code 5 2. Introduction to Chef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 The Chef Framework 9 The Chef Tool 10 The Chef API 11 The Chef Community 11 3. Getting Started with Chef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Installing Ruby 14 Getting Set Up on the Opscode Platform 16 Installing Chef 18 Using Chef to Write Infrastructure Code 19 4. Behavior-Driven Development (BDD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 A Very Brief History of Agile Software Development 23 Test-Driven Development 24 Behavior-Driven Development 25 Building the Right Thing 26 Reducing Risk 26 Evolving Design 26 Cucumber 27 5. Introduction to Cucumber-Chef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Prerequisites 31 Sign up for Amazon Web Services 31 v www.it-ebooks.info Installation 35 6. Cucumber-Chef: A Worked Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Introducing the Bram Consulting Group (BCG) 40 Gathering Requirements 40 Writing Acceptance Tests 43 Creating a Project with Cucumber-Chef 45 Making Tests Pass 47 Cooking with Chef 50 Resources 50 Recipes 51 Cookbooks 52 Roles 52 Running Chef 53 On With the Show 55 Databags 58 Making It Live 65 Environments 66 7. Next Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Managing Risk 71 Continuous Integration and Deployment 71 Monitoring 72 Conclusion 73 Further Reading 73 vi | Table of Contents www.it-ebooks.info Preface Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. Constant width Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords. Constant width bold Shows commands or other text that should be typed literally by the user. Constant width italic Shows text that should be replaced with user-supplied values or by values deter- mined by context. This icon signifies a tip, suggestion, or general note. This icon indicates a warning or caution. vii www.it-ebooks.info Using Code Examples This book is here to help you get your job done. In general, you may use the code in this book in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission. We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Test-Driven Infrastructure with Chef by Stephen Nelson-Smith (O’Reilly). Copyright 2011 Atalanta Systems LTD, 978-1-449-30481-2.” If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com. Safari® Books Online Safari Books Online is an on-demand digital library that lets you easily search over 7,500 technology and creative reference books and videos to find the answers you need quickly. With a subscription, you can read any page and watch any video from our library online. Read books on your cell phone and mobile devices. Access new titles before they are available for print, and get exclusive access to manuscripts in development and post feedback for the authors. Copy and paste code samples, organize your favorites, down- load chapters, bookmark key sections, create notes, print out pages, and benefit from tons of other time-saving features. O’Reilly Media has uploaded this book to the Safari Books Online service. To have full digital access to this book and others on similar topics from O’Reilly and other pub- lishers, sign up for free at http://my.safaribooksonline.com. How to Contact Us Please address comments and questions concerning this book to the publisher: O’Reilly Media, Inc. 1005 Gravenstein Highway North Sebastopol, CA 95472 800-998-9938 (in the United States or Canada) 707-829-0515 (international or local) 707-829-0104 (fax) viii | Preface www.it-ebooks.info [...]... for Chef: $ rvm gemset create chef 'chef' gemset created (/home/USER/.rvm/gems/ruby-1.9.2-p180 @chef) We can now switch to that gemset simply by typing: $ rvm use 1.9.2 @chef Using /home/USER/.rvm/gems/ruby-1.9.2-p180 with gemset chef Now install Chef: $ gem install chef Verify that Chef is installed with: $ chef- client -v Chef: 0.10.0 Using Chef to Write Infrastructure Code Now that we have Ruby and Chef. .. subject of Chef itself 12 | Chapter 2: Introduction to Chef www.it-ebooks.info CHAPTER 3 Getting Started with Chef Having given a high-level overview of what Chef is, we now turn to getting ourselves set up to use Chef and into a position where we can use it to write code to model, build, and test our infrastructure We’re going to use the Opscode Platform for all our examples Although the Chef server... debugging and exploring the data held on the Chef server 3 A fully-featured stand-alone configuration management tool, Chef- solo, which allows access to a subset of Chef s features, suitable for simple deployments 4 The Chef client—an agent that runs on systems being managed by Chef, and the primary mechanism by which such systems communicate with the Chef server Chef- client uses the framework’s library... ready to start using Chef: 1 Install Ruby 2 Install Chef 3 Set up our workstation to interact with the Chef API via the Opscode Platform The Chef libraries and tools that make up the framework are distributed as RubyGems Distribution-specific packages are maintained by Opscode (for Debian and Ubuntu) and various other third parties I recommend using RubyGems Chef is a fast-moving tool, with a responsive... implemented with very little technology, and with good leadership However the final area—that of testing infrastructure is a difficult endeavor As such, it is the subject of this book—a manifesto for bravely rethinking how we develop infrastructure code The Risks of Infrastructure as Code | 7 www.it-ebooks.info www.it-ebooks.info CHAPTER 2 Introduction to Chef Chef is an open source tool and framework... to start using Chef to apply the Infrastructure as Code paradigm Given that the whole paradigm we are discussing is about managing our infrastructure as code, our first step must be to create a repository for our work The quickest way to do this is to clone the example Chef repository from Opscode’s GitHub account: $ git clone http://github.com/opscode /chef- repo.git Using Chef to Write Infrastructure. .. an API client—the user is associated with an organization, and thus able to make API calls via the API If you saw similar results to the above, you’re ready to learn how to cook with Chef! 22 | Chapter 3: Getting Started with Chef www.it-ebooks.info CHAPTER 4 Behavior -Driven Development (BDD) In Chapter 1, I argued that to mitigate against the risks of adopting the Infrastructure as Code paradigm, systems... Rightscale and Wikia use Chef to automate the deploying of thousands of servers with a wide variety of applications and environments Chef users can share their “recipes” for installing and configuring software with “cookbooks” on http://community.opscode.com Cookbooks exist for a large number of packages, with over 200 cookbooks available on http://community.opscode.com The Chef Community | 11 www.it-ebooks.info... executed, will result in that infrastructure coming to life The Risks of Infrastructure as Code Although the potential benefits of Infrastructure as Code are hard to overstate, it must be pointed out that this approach is not without its dangers Production infrastructures that handle high-traffic websites are hugely complicated Consider, for example, the The Risks of Infrastructure as Code | 5 www.it-ebooks.info... framework that provides system administrators and developers with a foundation of APIs and libraries with which to build tools for managing infrastructure at scale Let’s explore this a little further Chef is a framework, a tool, and an API The Chef Framework As the discipline of software development has matured, frameworks have emerged, with the aim of reducing development time by minimizing the overhead . www.it-ebooks.info www.it-ebooks.info Test- Driven Infrastructure with Chef www.it-ebooks.info www.it-ebooks.info Test- Driven Infrastructure with Chef Stephen Nelson-Smith Beijing • Cambridge • Farnham • Köln • Sebastopol • Tokyo www.it-ebooks.info Test- Driven. 40 Writing Acceptance Tests 43 Creating a Project with Cucumber -Chef 45 Making Tests Pass 47 Cooking with Chef 50 Resources 50 Recipes 51 Cookbooks 52 Roles 52 Running Chef 53 On With the Show 55 Databags. Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Test- Driven Infrastructure with Chef, the image of edible-nest swiftlets, and related trade dress are trademarks

Ngày đăng: 01/08/2014, 17:48

TỪ KHÓA LIÊN QUAN

w