You are previewing Extending Puppet - Second Edition.
O'Reilly logo
Extending Puppet - Second Edition

Book Description

Start pulling the strings of your infrastructure with Puppet – learn how to configure, customize, and manage your systems more intelligently

About This Book

  • Explore the wider Puppet ecosystem of useful tools

  • Design and manage your Puppet architecture for optimum performance

  • Write more efficient code that keeps your infrastructure more robust

  • Who This Book Is For

    If you are a Puppet user, this book will help you on different levels. If you a beginner, we summarize the key Puppet components and give you the elements to have a broader vision. For more experienced users, you will be surprised by with topics on designing, implementing, adapting, and deploying Puppet architectures. If you are expert, you will find topics and information that is rarely exposed in other books, giving you an insight into Puppet's future and its usage on alternative devices.

    What You Will Learn

  • Learn the principles of Puppet language and ecosystem

  • Extract the features of Hiera and PuppetDB’s power usage

  • Explore the different approaches to Puppet architecture design

  • Use Puppet to manage network, cloud, and virtualization devices

  • Manage and test the Puppet code workflow

  • Tweak, hack, and adapt the Puppet extension points

  • Get a run through of the strategies and patterns to introduce Puppet automation

  • Master the art of writing reusable modules

  • In Detail

    Puppet has changed the way we manage our systems, but Puppet itself is changing and evolving, and so are the ways we are using it. To tackle our IT infrastructure challenges and avoid common errors when designing our architectures, an up-to-date, practical, and focused view of the current and future Puppet evolution is what we need. With Puppet, you define the state of your IT infrastructure, and it automatically enforces the desired state.

    This book will be your guide to designing and deploying your Puppet architecture. It will help you utilize Puppet to manage your IT infrastructure. Get to grips with Hiera and learn how to install and configure it, before learning best practices for writing reusable and maintainable code. You will also be able to explore the latest features of Puppet 4, before executing, testing, and deploying Puppet across your systems. As you progress, Extending Puppet takes you through higher abstraction modules, along with tips for effective code workflow management.

    Finally, you will learn how to develop plugins for Puppet - as well as some useful techniques that can help you to avoid common errors and overcome everyday challenges.

    Style and approach

    This is a collection of specific information about multiple topics related to Puppet and its ecosystem. Starting from a review of the very basics to more advanced topics, mixing practical advice with important theory and broader perspective, along with implementation details.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Extending Puppet Second Edition
      1. Table of Contents
      2. Extending Puppet Second Edition
      3. Credits
      4. About the Authors
      5. About the Reviewer
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Errata
          2. Piracy
          3. Questions
      8. 1. Puppet Essentials
        1. The Puppet ecosystem
          1. Why configuration management matters
        2. Puppet components
        3. Installing and configuring Puppet
        4. Puppet in action
          1. Resources
          2. The resource abstraction layer
          3. Nodes
          4. Classes and defines
          5. Class inheritance
          6. Resource defaults
          7. Resource references
        5. Variables, facts, and scopes
          1. System's facts
          2. External facts
          3. User variables in Puppet DSL
          4. Type-checking
          5. User variables in an ENC
          6. User variables in Hiera
          7. Puppet built-in variables
          8. Variables scope
        6. Meta parameters
        7. Managing order and dependencies
          1. Run stages
        8. Reserved names and allowed characters
        9. Conditionals
        10. Comparison operators
        11. Iteration and lambdas
          1. The in operator
          2. Expressions combinations
        12. Exported resources
          1. Virtual resources
        13. Modules
          1. Paths of a module and auto loading
          2. Templates
        14. Restoring files from a filebucket
        15. Summary
      9. 2. Managing Puppet Data with Hiera
        1. Installing and configuring Hiera
          1. The hiera.yaml configuration file
            1. Global settings
            2. Backend specific settings
            3. Examples
        2. Working with the command line on a YAML backend
        3. Using Hiera in Puppet
          1. Dealing with hashes in Puppet code
          2. Puppet 3 automatic parameter lookup
          3. Evolving usage patterns for class parameters
        4. Additional Hiera backends
          1. Hiera-file
          2. Encryption plugins
            1. Hiera-gpg
          3. Hiera-eyaml
          4. Hiera-http, hiera-mysql
        5. Using Hiera as an ENC
        6. Summary
      10. 3. Introducing PuppetDB
        1. Installation and configuration
          1. Installing PuppetDB
          2. PuppetDB configurations
            1. Init script configuration
            2. Configuration settings
            3. Logging configuration
          3. Configurations on the Puppet Master
        2. Dashboards
          1. PuppetDB performance dashboard
          2. Puppetboard—Querying PuppetDB from the Web
        3. PuppetDB API
          1. Querying PuppetDB (read)
          2. PuppetDB commands (write)
        4. Querying PuppetDB for fun and profit
          1. /facts endpoint
          2. /resources endpoint
          3. /nodes endpoint
          4. /catalogs endpoint
          5. /fact-names endpoint
          6. /metrics endpoint
          7. /reports endpoint
          8. /events endpoint
          9. /event-counts endpoint
          10. /aggregated-event-counts endpoint
          11. /server-time endpoint
          12. /version endpoint
        5. The puppetdbquery module
          1. Query format
            1. Querying from the command line
            2. Querying from Puppet manifests
            3. The PuppetDB Hiera backend
        6. How Puppet code may change in the future
        7. Summary
      11. 4. Designing Puppet Architectures
        1. Components of a Puppet architecture
          1. Definition of the classes to include in each node
          2. Definition of the parameters to use for each node
          3. Definition of the configuration files provided to the nodes
          4. Definition of custom resources and classes
        2. The Foreman
        3. Roles and profiles
        4. The data and the code
        5. Sample architectures
          1. The default approach
          2. Basic ENC, logic on site module, Hiera backend
          3. The Foreman and Hiera
          4. Hiera-based setup
          5. Foreman smart variables
          6. Facts-driven truths
          7. Nodeless site.pp
        6. Summary
      12. 5. Using and Writing Reusable Modules
        1. Modules layout evolution
          1. Class parameters—from zero to data bindings
          2. Params pattern
          3. Data in modules
          4. Files and class names
          5. The anchor pattern
        2. The parameters dilemma
          1. Naming standards
        3. Reusability patterns
          1. Managing files
            1. Managing configuration hash patterns
            2. Managing multiple configuration files
            3. Managing users and dependencies
            4. Managing installation options
            5. Managing extra resources
        4. Summary
      13. 6. Higher Abstraction Modules
        1. The OpenStack example
          1. Component (application) modules
          2. Raising abstraction – the official OpenStack module
          3. Raising abstraction – Puppet Labs OpenStack module
          4. Taking an alternate approach
        2. An approach to reusable stack modules
        3. Tiny Puppet
        4. Summary
      14. 7. Puppet Migration Patterns
        1. Examining potential scenarios and approaches
          1. New infrastructures
          2. Existing manually managed infrastructures
            1. Node migration
            2. Node update
          3. Existing automated infrastructures
        2. Patterns for extending Puppet coverage
          1. Raising the bar, step by step
          2. Knowing the territory
          3. Defining priorities
          4. Evaluating solutions
          5. Coding
          6. Applying changes
        3. Things change
          1. Puppet friendly infrastructure
          2. Puppet-friendly software
        4. Summary
      15. 8. Code Workflow Management
        1. Write Puppet code
          1. Geppetto
          2. Vim
        2. Git workflows
          1. Code management using Git
          2. Git hooks
          3. Environments and branches
            1. Branch based automatic environments
            2. Simplified developer workdir environments
        3. Code review
          1. Gerrit
          2. Online resources for peer review
        4. Testing Puppet code
          1. Using rspec-puppet
          2. Vagrant
          3. Beaker and beaker-rspec
        5. Deploying Puppet code
          1. Using librarian-puppet for deployments
          2. Deploying code with r10k
        6. Propagating Puppet changes
        7. Puppet continuous integration
          1. Travis
          2. Jenkins
        8. Summary
      16. 9. Scaling Puppet Infrastructures
        1. Scaling Puppet
          1. As simple as puppet apply
          2. Default Puppet Master
          3. Puppet Master with Passenger
            1. Installing and configuring Passenger
          4. Puppet Master based on Trapperkeeper
          5. Multi-Master scaling
            1. Managing certificates
            2. Managing SSL termination
            3. Managing code and data
          6. Load balancing alternatives
          7. Masterless Puppet
          8. Configurations and infrastructure optimizations
            1. Traffic compression
            2. Caching
            3. Distributing Puppet run times
            4. File system changes check
            5. Scaling stored configs
        2. Measuring performance
          1. Puppet Metrics
          2. Optimizing code
          3. Testing different Puppet versions
        3. Summary
      17. 10. Extending Puppet
        1. Anatomy of a Puppet run, under the hood
        2. Puppet extension alternatives
          1. ENC and Hiera Extendibility
          2. Modules pluginsync
          3. Puppet indirector and its termini
        3. Custom functions
        4. Custom facts
          1. Ruby facts distributed via pluginsync
          2. External facts in facts.d directory
        5. Custom types and providers
        6. Custom report handlers
        7. Custom faces
        8. Summary
      18. 11. Beyond the System
        1. Puppet on network equipment
          1. Proxy mode with Puppet device application
          2. Native Puppet on network equipment
            1. Cisco onePK
            2. Juniper and the netdev_stdlib
        2. Puppet for cloud and virtualization
          1. VMware
            1. VM provisioning on vCenter and vSphere
            2. vCenter configuration
            3. vSphere virtual machine management with resource types
          2. Amazon Web Services
            1. Cloud provisioning on AWS
          3. AWS provisioning and configuration with resource types
            1. Managing CloudFormation
          4. Cloud provisioning on Google Compute Engine
        3. Puppet on storage devices
        4. Puppet and Docker
        5. Summary
      19. 12. Future Puppet
        1. Changing the serialization format
        2. Direct Puppet
          1. File sync
        3. Other changes
          1. Certificate authority in Clojure
          2. Package management
          3. Changes in faces
        4. Beyond Puppet 4.x
        5. Summary
      20. Index