DevOps for Developers Michael Hüttermann DevOps for Developers Copyright © 2012 by Michael Hüttermann This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publica- tion or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher's location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law. ISBN 978-1-4302-4569-8 ISBN 978-1-4302-4570-4 (eBook) Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publica- tion, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. President and Publisher: Paul Manning Lead Editor: Ben Renow-Clarke Technical Reviewers: Patrick Debois, Lisa Crispin Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Louise Corrigan, Morgan Ertel, Jonathan Gennick, Jonathan Hassell, Robert Hutchinson, Michelle Lowman, James Markham, Matthew Moodie, Jeff Olson, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Gwenan Spearing, Matt Wade, Tom Welsh Coordinating Editor: Anamika Panchoo Copy Editor: Mary Bearden Compositor: SPi Global Indexer: SPi Global Artist: SPi Global Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer- sbm.com, or visit www.springeronline.com. For information on translations, please e-mail [email protected], or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales. Dedication For my wife, my two sons, and Doctor Snuggles, my cat. Contents at a Glance About the Author ..................................................................................xiii About the Technical Reviewers ............................................................xiv Acknowledgments .................................................................................xv Introduction ..........................................................................................xvi (cid:78) Part I: Fundamentals ............................................................................1 (cid:78) Chapter 1: Beginning DevOps for Developers .......................................3 (cid:78) Chapter 2: Introducing DevOps ...........................................................15 (cid:78) Chapter 3: Building Blocks of DevOps ................................................33 (cid:78) Part II: Metrics and Measurement View .............................................49 (cid:78) Chapter 4: Quality and Testing ...........................................................51 (cid:78) Chapter 5: Introduce Shared Incentives .............................................65 (cid:78) Part III: Process View .........................................................................79 (cid:78) Chapter 6: Gain Fast Feedback ...........................................................81 (cid:78) Chapter 7: Unified and Holistic Approach ...........................................95 (cid:78) Part IV: Technical View .....................................................................109 (cid:78) Chapter 8: Automatic Releasing .......................................................111 (cid:78) Chapter 9: Infrastructure as Code ....................................................135 (cid:78) Chapter 10: Specification by Example ..............................................157 Index ....................................................................................................171 Contents About the Author ..................................................................................xiii About the Technical Reviewers ............................................................xiv Acknowledgments .................................................................................xv Introduction ..........................................................................................xvi (cid:78) Part I: Fundamentals ............................................................................1 (cid:78) Chapter 1: Beginning DevOps for Developers .......................................3 The Definition of DevOps ................................................................................3 Influences and Origins ......................................................................................................5 Development and Operations in Conflict ..........................................................................5 Broaden the Usage of Agile ..............................................................................................7 Views of DevOps ...............................................................................................................8 What DevOps Is NOT .......................................................................................9 Roles and Structures ........................................................................................................9 DevOps and Tool Suites ..................................................................................................11 Structure of This Book ..................................................................................12 Conclusion ....................................................................................................12 (cid:78) Chapter 2: Introducing DevOps ...........................................................15 Traditional Project Settings ..........................................................................15 Agile Project Settings ...................................................................................18 Blame Game: Dev vs. Ops ............................................................................21 Conflicts During Deployment ..........................................................................................21 Conflicts After Deployment .............................................................................................22 Conflicts About Performance ..........................................................................................22 viii CONTENTS Operations as Bottleneck .............................................................................23 Horizontal Optimization ..................................................................................................24 Operations and ITSM ......................................................................................................24 DevOps to the Rescue ..................................................................................26 The Essence of DevOps ................................................................................26 Values and Goals ............................................................................................................27 Processes .......................................................................................................................28 Tools ...............................................................................................................................29 Conclusion ....................................................................................................31 (cid:78) Chapter 3: Building Blocks of DevOps ................................................33 Measurement and Metrics ...........................................................................33 Traditional Use of Metrics ...............................................................................................34 Agile Approach to Metrics...............................................................................................34 Improving Flow of Features ..........................................................................38 Cycle Time ......................................................................................................................38 Lead Time, Takt Time, and Throughput ............................................................................39 Improve and Accelerate Delivery ..................................................................40 Automatic Releasing .......................................................................................................41 Decoupled Deployment and Release ..............................................................................45 Conclusion ....................................................................................................47 (cid:78) Part II: Metrics and Measurement View .............................................49 (cid:78) Chapter 4: Quality and Testing ...........................................................51 What Is Quality? ...........................................................................................51 Leading and Supporting Attributes .................................................................................52 Patterns for Improving Quality .....................................................................54 Internal and External Quality ..........................................................................................55 Use Scenarios to Describe Quality ..................................................................................55 Quality Is an Inherent Part ..............................................................................................56 CONTENTS ix Test Automation Mix .......................................................................................................58 Inject Quality Gates .........................................................................................................61 Conclusion ....................................................................................................64 (cid:78) Chapter 5: Introduce Shared Incentives .............................................65 War Study: Magic Kingdoms ........................................................................65 What Is a Team? ...........................................................................................66 Goals and Working Agreements ......................................................................................67 Motivation .......................................................................................................................69 Becoming a Team .........................................................................................70 Tuckman’s Stages of Group Development ......................................................................71 Facilitator and Caretakers ..............................................................................................72 Success Stories ............................................................................................72 Aaron Nichols: DevOps at Rally Software .......................................................................73 Lisa Crispin: DevOps, Naturally .......................................................................................76 Conclusion ....................................................................................................77 (cid:78) Part III: Process View .........................................................................79 (cid:78) Chapter 6: Gain Fast Feedback ...........................................................81 The DevOps Area Matrix ...............................................................................81 Extend Development to Operations ..............................................................82 Extend Operations to Development ..............................................................83 Embed Development into Operations ...........................................................84 Embed Operations into Development ...........................................................85 Starting with Kanban ....................................................................................86 Introducing Kanban ........................................................................................................86 Five Core Properties .......................................................................................................87 An Example Kanban Board for DevOps ...........................................................................88 x CONTENTS Example Use Case ........................................................................................89 The Anarchic Approach ...................................................................................................90 The Improved Approach ..................................................................................................92 Conclusion ....................................................................................................94 (cid:78) Chapter 7: Unified and Holistic Approach ...........................................95 Getting Started with Concepts .....................................................................95 Nonfunctional Requirements ..........................................................................................96 Origins of Conceptual Deficits ......................................................................99 Limited Rationality ........................................................................................................100 Complex and Dynamic Environments ...........................................................................101 Principal-Agent Problem ...............................................................................................101 Moral Hazard ................................................................................................................102 Attributes of a Unified Approach ................................................................104 Foster Traceability ........................................................................................................104 Check Nonfunctional Requirements .............................................................................106 Align Goals ....................................................................................................................106 Conclusion ..................................................................................................107 (cid:78) Part IV: Technical View .....................................................................109 (cid:78) Chapter 8: Automatic Releasing .......................................................111 Prerequisites for Automatic Releasing .......................................................111 Patterns with Appropriate Tools .................................................................114 Use Delivery Pipelines ..................................................................................................114 Use Baselines ...............................................................................................................117 Shared Version Numbers ..............................................................................................121 Version Automatically ...................................................................................................122 Use Release Containers with RPM ................................................................................125 Apply Task-Based Development ...................................................................................128 Use Database Update Scripts .......................................................................................130 Conclusion ..................................................................................................133 CONTENTS xi (cid:78) Chapter 9: Infrastructure as Code ....................................................135 Starting with Infrastructure as Code ..........................................................136 Traditional Infrastructure Handling ...............................................................................136 How to Do It Better .......................................................................................................137 Test Environments with Vagrant .................................................................139 Host-Only Networking, Multi-VM Environments ...........................................................142 Provisioning with Puppet ..............................................................................................142 Using Vagrant for Continuous Integration .....................................................................144 Complementary Tools ...................................................................................................147 Provisioning with Puppet ............................................................................148 Setting Up a Puppet Master ..........................................................................................148 Setting Up a Puppet Client ............................................................................................148 Use Case: Open Source Infrastructure with Puppet ...................................150 The Need, from the Jenkins Viewpoint .........................................................................150 The How at Jenkins ......................................................................................................151 Where to Look Next? ..................................................................................155 Alternatives...................................................................................................................156 Conclusion ..................................................................................................156 (cid:78) Chapter 10: Specification by Example ..............................................157 Getting Started with Acceptance Tests .......................................................157 Acceptance Tests as a Communication Vehicle ............................................................158 Defining Your Acceptance Criteria ..............................................................159 Elaborating the Examples .............................................................................................160 Automating the Acceptance Criteria .............................................................................161 Implementing the Tests ................................................................................................163 Slice High-Level Tests into Steps .................................................................................163 Table-Driven Tests ........................................................................................................164 Test Steps as Java or Groovy Classes ..........................................................................165