Puppet Cookbook - Third Edition

Book description

Jump-start your Puppet deployment using engaging and practical recipes

In Detail

Puppet is a configuration management system that automates all your IT configurations, giving you control of what you do to each node, when you do it, and how you do it.

Puppet Cookbook Third Edition takes the reader from a basic knowledge of Puppet to a complete and expert understanding of Puppet's latest and most advanced features. Updated with the latest advancements and best practices, it gives you a clear view on how to "connect the dots" and expands your knowledge to successfully use and extend Puppet.

This book delves into various aspects of writing good Puppet code, which includes using Puppet community style, checking your manifests with puppet-lint, and learning community best practices, with an emphasis on real-world implementation.

What You Will Learn

  • Install and set up Puppet for the first time
  • Discover the latest, most advanced, and experimental features of Puppet
  • Bootstrap your Puppet installation
  • Master techniques to deal with centralized and decentralized Puppet deployments
  • Use exported resources and forge modules
  • Create efficient manifests to streamline your deployments
  • Automate Puppet master deployment using Git hooks, r10k, and PuppetDB
  • Make Puppet reliable, performant, and scalable

Table of contents

  1. Puppet Cookbook Third Edition
    1. Table of Contents
    2. Puppet Cookbook Third Edition
    3. Credits
    4. About the Authors
    5. About the Reviewers
    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. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Puppet Language and Style
      1. Introduction
      2. Adding a resource to a node
        1. How to do it...
        2. How it works...
      3. Using Facter to describe a node
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Variables
          2. Scope
      4. Installing a package before starting a service
        1. How to do it...
        2. How it works...
          1. Capitalization
          2. Learning metaparameters and ordering
          3. Trifecta
          4. Idempotency
      5. Installing, configuring, and starting a service
        1. How to do it...
        2. How it works…
      6. Using community Puppet style
        1. How to do it…
          1. Indentation
          2. Quoting
          3. False
          4. Variables
          5. Parameters
          6. Symlinks
      7. Creating a manifest
        1. How to do it...
        2. There's more…
      8. Checking your manifests with Puppet-lint
        1. Getting ready
        2. How to do it...
        3. There's more...
        4. See also
      9. Using modules
        1. How to do it…
        2. How it works…
        3. There's more…
          1. Templates
          2. Facts, functions, types, and providers
        4. Third-party modules
          1. Module organization
        5. See also
      10. Using standard naming conventions
        1. How to do it…
        2. There's more…
      11. Using inline templates
        1. How to do it…
        2. How it works…
        3. There's more...
        4. See also
      12. Iterating over multiple items
        1. How to do it…
        2. How it works…
        3. There's more…
          1. Using hashes
          2. Creating arrays with the split function
      13. Writing powerful conditional statements
        1. How to do it…
        2. How it works…
        3. There's more…
          1. Elseif branches
          2. Comparisons
          3. Combining expressions
        4. See also
      14. Using regular expressions in if statements
        1. How to do it…
        2. How it works…
        3. There's more…
          1. Capturing patterns
          2. Regular expression syntax
        4. See also
      15. Using selectors and case statements
        1. How to do it…
        2. How it works…
          1. Selector
          2. Case statement
        3. There's more…
          1. Regular expressions
          2. Defaults
      16. Using the in operator
        1. How to do it…
        2. There's more…
      17. Using regular expression substitutions
        1. How to do it…
        2. How it works…
        3. There's more…
        4. See also
      18. Using the future parser
        1. Getting ready
        2. How to do it...
          1. Appending to and concatenating arrays
          2. Lambda functions
            1. Reduce
            2. Filter
            3. Map
            4. Slice
            5. Each
            6. Other features
    9. 2. Puppet Infrastructure
      1. Introduction
      2. Installing Puppet
        1. Getting ready
        2. How to do it...
      3. Managing your manifests with Git
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      4. Creating a decentralized Puppet architecture
        1. Getting ready
        2. How to do it...
        3. How it works...
      5. Writing a papply script
        1. How to do it...
        2. How it works...
      6. Running Puppet from cron
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      7. Bootstrapping Puppet with bash
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      8. Creating a centralized Puppet infrastructure
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      9. Creating certificates with multiple DNS names
        1. Getting ready
        2. How to do it...
        3. How it works...
      10. Running Puppet from passenger
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      11. Setting up the environment
        1. Getting ready
        2. How to do it...
        3. There's more...
      12. Configuring PuppetDB
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      13. Configuring Hiera
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      14. Setting node-specific data with Hiera
        1. Getting ready
        2. How to do it...
        3. How it works...
      15. Storing secret data with hiera-gpg
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      16. Using MessagePack serialization
        1. Getting ready
        2. How to do it...
        3. How it works...
      17. Automatic syntax checking with Git hooks
        1. How to do it...
        2. How it works...
      18. Pushing code around with Git
        1. Getting ready
        2. How to do it...
        3. How it works...
      19. Managing Environments with Git
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    10. 3. Writing Better Manifests
      1. Introduction
      2. Using arrays of resources
        1. How to do it…
        2. How it works…
        3. See also
      3. Using resource defaults
        1. How to do it...
        2. How it works...
        3. There's more...
      4. Using defined types
        1. How to do it…
        2. How it works…
        3. There's more…
        4. See also
      5. Using tags
        1. How to do it...
        2. There's more…
      6. Using run stages
        1. How to do it…
        2. How it works…
        3. There's more…
        4. See also
      7. Using roles and profiles
        1. How to do it…
        2. How it works…
        3. There's more…
      8. Passing parameters to classes
        1. How to do it…
        2. How it works…
        3. There's more…
          1. Specifying default values
      9. Passing parameters from Hiera
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      10. Writing reusable, cross-platform manifests
        1. How to do it…
        2. How it works...
        3. There's more…
        4. See also
      11. Getting information about the environment
        1. How to do it…
        2. How it works…
        3. There's more…
        4. See also
      12. Importing dynamic information
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      13. Passing arguments to shell commands
        1. How to do it…
        2. How it works…
    11. 4. Working with Files and Packages
      1. Introduction
      2. Making quick edits to config files
        1. Getting ready
        2. How to do it...
        3. How it works…
        4. There's more…
      3. Editing INI style files with puppetlabs-inifile
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      4. Using Augeas to reliably edit config files
        1. How to do it…
        2. How it works…
        3. There's more…
      5. Building config files using snippets
        1. Getting ready
        2. How to do it...
        3. How it works...
      6. Using ERB templates
        1. How to do it…
        2. How it works…
        3. There's more…
        4. See also
      7. Using array iteration in templates
        1. How to do it…
        2. How it works…
        3. There's more…
        4. See also
      8. Using EPP templates
        1. How to do it...
        2. How it works...
        3. There's more...
      9. Using GnuPG to encrypt secrets
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      10. Installing packages from a third-party repository
        1. How to do it…
        2. How it works…
        3. There's more...
      11. Comparing package versions
        1. How to do it…
        2. How it works…
    12. 5. Users and Virtual Resources
      1. Introduction
      2. Using virtual resources
        1. How to do it...
        2. How it works...
        3. There's more...
      3. Managing users with virtual resources
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      4. Managing users' SSH access
        1. How to do it...
        2. How it works...
        3. There's more...
      5. Managing users' customization files
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      6. Using exported resources
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    13. 6. Managing Resources and Files
      1. Introduction
      2. Distributing cron jobs efficiently
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      3. Scheduling when resources are applied
        1. How to do it...
        2. How it works...
        3. There's more...
      4. Using host resources
        1. How to do it...
        2. How it works...
        3. There's more...
      5. Using exported host resources
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      6. Using multiple file sources
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      7. Distributing and merging directory trees
        1. How to do it...
        2. How it works...
        3. There's more...
      8. Cleaning up old files
        1. How to do it...
        2. How it works...
        3. There's more...
      9. Auditing resources
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      10. Temporarily disabling resources
        1. How to do it...
        2. How it works...
    14. 7. Managing Applications
      1. Introduction
      2. Using public modules
        1. How to do it...
        2. How it works...
        3. There's more...
      3. Managing Apache servers
        1. How to do it...
        2. How it works...
      4. Creating Apache virtual hosts
        1. How to do it...
        2. How it works...
        3. There's more...
      5. Creating nginx virtual hosts
        1. How to do it...
        2. How it works...
        3. There's more...
      6. Managing MySQL
        1. How to do it...
        2. How it works...
        3. There's more...
      7. Creating databases and users
        1. How to do it...
        2. How it works...
        3. There's more...
    15. 8. Internode Coordination
      1. Introduction
      2. Managing firewalls with iptables
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      3. Building high-availability services using Heartbeat
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more...
      4. Managing NFS servers and file shares
        1. How to do it...
        2. How it works…
      5. Using HAProxy to load-balance multiple web servers
        1. How to do it…
        2. How it works…
        3. There's more...
      6. Managing Docker with Puppet
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    16. 9. External Tools and the Puppet Ecosystem
      1. Introduction
      2. Creating custom facts
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      3. Adding external facts
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Debugging external facts
          2. Using external facts in Puppet
        5. See also
      4. Setting facts as environment variables
        1. How to do it...
      5. Generating manifests with the Puppet resource command
        1. How to do it...
        2. There's more...
      6. Generating manifests with other tools
        1. Getting ready
        2. How to do it...
        3. There's more...
      7. Using an external node classifier
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      8. Creating your own resource types
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Documentation
          2. Validation
      9. Creating your own providers
        1. How to do it...
        2. How it works...
        3. There's more...
      10. Creating custom functions
        1. How to do it...
        2. How it works...
        3. There's more...
      11. Testing your puppet manifests with rspec-puppet
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      12. Using librarian-puppet
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      13. Using r10k
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    17. 10. Monitoring, Reporting, and Troubleshooting
      1. Introduction
      2. Noop – the don't change anything option
        1. How to do it...
        2. How it works...
        3. There's more...
        4. See also
      3. Logging command output
        1. How to do it...
        2. How it works...
        3. There's more...
      4. Logging debug messages
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Printing out variable values
          2. Resource ordering
      5. Generating reports
        1. How to do it...
        2. How it works...
        3. There's more...
          1. Other report types
        4. See also
      6. Producing automatic HTML documentation
        1. How to do it...
        2. How it works...
        3. There's more...
      7. Drawing dependency graphs
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      8. Understanding Puppet errors
        1. How to do it...
        2. See also
      9. Inspecting configuration settings
        1. How to do it...
        2. How it works...
        3. See also
    18. Index

Product information

  • Title: Puppet Cookbook - Third Edition
  • Author(s): Thomas Uphill, John Arundel
  • Release date: February 2015
  • Publisher(s): Packt Publishing
  • ISBN: 9781784394882