Extending Facter and Puppet
Total Page:16
File Type:pdf, Size:1020Kb
Pro Puppet James Turnbull Jeffrey McCune Pro Puppet Copyright © 2011 by James Turnbull and Jeffrey McCune All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN 978-1-4302-3057-1 ISBN 978-1-4302-3058-8 (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. President and Publisher: Paul Manning Lead Editor: Frank Pohlmann Technical Reviewer: Jessica Fraser Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Jeff Olson, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Anita Castro Copy Editor: Seth Kline Compositor: Bytheway Publishing Services Indexer: John Collin Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 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. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at www.apress.com. You will need to answer questions pertaining to this book in order to successfully download the code. Dedicated to my partner and best friend, Ruth Brown, who continues to be wonderful. James Turnbull Dedicated to my parents, Pete and Gloria, who year after year accommodate my inability to shut the laptop while on vacation with them, and to Dave Alden for teaching me about configuration management, being a great mentor, and encouraging me to learn. Jeff McCune CONTENTS AT A GLANCE Contents at a Glance About the Authors................................................................................................xiii About the Technical Reviewer ............................................................................. xiv Acknowledgments ................................................................................................ xv Introduction ......................................................................................................... xvi Chapter 1: Getting Started with Puppet..................................................................1 Chapter 2: Building Hosts with Puppet.................................................................29 Chapter 3: Working with Environments................................................................65 Chapter 4: Puppet Scalability ...............................................................................89 Chapter 5: Externalizing Puppet Configuration...................................................119 Chapter 6: Exporting and Storing Configuration.................................................133 Chapter 7: Puppet Consoles: Puppet Dashboard and The Foreman....................159 Chapter 8: Tools and Integration ........................................................................189 Chapter 9: Reporting with Puppet ......................................................................231 Chapter 10: Extending Facter and Puppet ..........................................................241 Chapter 11: Marionette Collective ......................................................................265 Appendix A: Working with Puppet ......................................................................289 Index ...................................................................................................................293 iv CONTENTS Contents About the Authors................................................................................................xiii About the Technical Reviewer ............................................................................. xiv Acknowledgments ................................................................................................ xv Introduction ......................................................................................................... xvi Chapter 1: Getting Started with Puppet..................................................................1 What Is Puppet?.................................................................................................................1 Deployment .............................................................................................................................................. 2 Configuration Language and Resource Abstraction Layer........................................................................ 3 Transactional Layer .................................................................................................................................. 5 Selecting the Right Version of Puppet ...............................................................................6 Can I mix releases of Puppet? ...........................................................................................7 Installing Puppet................................................................................................................7 Installing on Red Hat Enterprise Linux and Fedora................................................................................... 8 Installing on Debian and Ubuntu............................................................................................................... 9 Installing on OpenSolaris.......................................................................................................................... 9 Installing from Source ............................................................................................................................ 10 Installing on Microsoft Windows ............................................................................................................ 10 Installing on other Platforms .................................................................................................................. 11 Configuring Puppet ..........................................................................................................11 The site.pp file........................................................................................................................................ 13 Firewall Configuration ............................................................................................................................ 14 Starting the Puppet Master .................................................................................................................... 14 Connecting Our First Agent..............................................................................................16 v CONTENTS Completing the Connection .................................................................................................................... 17 Creating Our First Configuration......................................................................................18 Extending the site.pp file........................................................................................................................ 19 Agent Configuration................................................................................................................................ 20 Creating our first module.................................................................................................21 Module Structure.................................................................................................................................... 21 The init.pp file......................................................................................................................................... 22 Applying Our First Configuration......................................................................................24 Summary .........................................................................................................................26 Resources........................................................................................................................27 Chapter 2: Building Hosts with Puppet.................................................................29 Getting Started.................................................................................................................30