You are previewing Puppet 3 Cookbook.
O'Reilly logo
Puppet 3 Cookbook

Book Description

An essential book if you have responsibility for servers. Real-world examples and code will give you Puppet expertise, allowing more control over servers, cloud computing, and desktops. A time-saving, career-enhancing tutorial.

  • Use Puppet 3 to take control of your servers and desktops, with detailed step-by-step instructions

  • Covers all the popular tools and frameworks used with Puppet: Dashboard, Foreman, MCollective, and more

  • Teaches you how to extend Puppet with custom functions, types, and providers

  • Packed with tips and inspiring ideas for using Puppet to automate server builds, deployments, and workflows

  • In Detail

    A revolution is happening in web operations. Configuration management tools can build servers in seconds, and automate your entire network. Tools like Puppet are essential to taking full advantage of the power of cloud computing, and building reliable, scalable, secure, high-performance systems. More and more systems administration and IT jobs require some knowledge of configuration management, and specifically Puppet.

    "Puppet 3 Cookbook" takes you beyond the basics to explore the full power of Puppet, showing you in detail how to tackle a variety of real-world problems and applications. At every step it shows you exactly what commands you need to type, and includes full code samples for every recipe.

    The book takes the reader from a basic knowledge of Puppet to a complete and expert understanding of Puppet’s latest and most advanced features, community best practices, writing great manifests, scaling and performance, and extending Puppet by adding your own providers and resources. It starts with guidance on how to set up and expand your Puppet infrastructure, then progresses through detailed information on the language and features, external tools, reporting, monitoring, and troubleshooting, and concludes with many specific recipes for managing popular applications.

    The book includes real examples from production systems and techniques that are in use in some of the world’s largest Puppet installations, including a distributed Puppet architecture based on the Git version control system. It covers common problems and errors and shows you how to troubleshoot your Puppet manifests. You’ll be introduced to powerful tools that work with Puppet such as Hiera and MCollective. You’ll learn how to use objection orientation and classes to write powerful, reusable manifests, and how to embed Ruby code in templates. You’ll find out how to extend Puppet with custom resource types and providers. The book also explains managing Rails applications and databases, building web servers, load balancers, high-availability systems with Heartbeat, and many other state-of-the-art techniques.

    Table of Contents

    1. Puppet 3 Cookbook
      1. Table of Contents
      2. Puppet 3 Cookbook
      3. Credits
      4. About the Author
      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 Infrastructure
        1. Introduction
          1. Linux distributions
          2. Puppet versions
        2. Installing Puppet
          1. Getting ready...
          2. How to do it...
        3. Creating a manifest
          1. How to do it...
        4. Managing your manifests with Git
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. There's more...
        5. Creating a decentralized Puppet architecture
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        6. Writing a papply script
          1. How to do it...
          2. How it works...
        7. Running Puppet from cron
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. There's more...
        8. Deploying changes with Rake
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        9. Bootstrapping Puppet with Rake
          1. Getting ready...
          2. How to do it...
          3. How it works...
        10. Automatic syntax checking with Git hooks
          1. How to do it…
          2. How it works…
      9. 2. Puppet Language and Style
        1. Introduction
        2. Using community Puppet style
          1. How to do it…
            1. Indentation
            2. Quoting
            3. Variables
            4. Parameters
            5. Symlinks
          2. There's more…
        3. Checking your manifests with puppet-lint
          1. Getting ready
          2. How to do it...
          3. There's more...
          4. See also
        4. Using modules
          1. How to do it…
          2. How it works…
          3. There's more…
            1. Templates
            2. Facts, functions, types, and providers
            3. Autogenerating module layout
            4. Third party modules
            5. Module organization
          4. See also
        5. Using standard naming conventions
          1. How to do it…
          2. There's more…
        6. Using inline templates
          1. How to do it…
          2. How it works…
          3. There's more...
          4. See also
        7. 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
        8. Writing powerful conditional statements
          1. How to do it…
          2. How it works…
          3. There's more…
            1. Elsif branches
            2. Comparisons
            3. Combining expressions
          4. See also
        9. 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
        10. 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
        11. Using the in operator
          1. How to do it…
          2. There's more…
        12. Using regular expression substitutions
          1. How to do it…
          2. How it works…
          3. There's more
          4. See also
      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 definitions
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        4. Using dependencies
          1. How to do it…
          2. How it works…
          3. There's more…
        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 node inheritance
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        8. Passing parameters to classes
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        9. Using class inheritance and overriding
          1. How to do it…
          2. How it works…
          3. There's more…
            1. Removing inherited attributes
            2. Adding extra values using +>
            3. Disabling resources
          4. See also
        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. How to do it…
          2. How it works…
          3. There's more…
        3. Using Augeas to automatically edit config files
          1. How to do it…
          2. How it works…
          3. There's more…
        4. Building config files using snippets
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        5. Using ERB templates
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        6. Using array iteration in templates
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        7. Using GnuPG to encrypt secrets
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Installing packages from a third-party repository
          1. How to do it…
          2. How it works…
          3. There's more...
          4. See also
        9. Building packages automatically from source
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        10. 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. See also
        6. Efficiently distributing cron jobs
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        7. Using schedules to limit when resources can be applied
          1. How to do it…
          2. How it works…
          3. There's more…
        8. Using host resources
          1. How to do it…
          2. How it works...
          3. There's more...
        9. Using multiple file sources
          1. How to do it…
          2. How it works…
          3. There's more...
          4. See also
        10. Distributing directory trees
          1. How to do it…
          2. How it works…
          3. There's more…
        11. Cleaning up old files
          1. How to do it…
          2. How it works…
          3. There's more…
        12. Auditing resources
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        13. Temporarily disabling resources
          1. How to do it…
          2. How it works…
      13. 6. Applications
        1. Introduction
        2. Managing Apache servers
          1. How to do it...
          2. There's more...
        3. Creating Apache virtual hosts
          1. How to do it…
          2. How it works…
          3. There's more…
            1. Custom domains and docroots
            2. Modifying all sites
          4. See also
        4. Creating Nginx virtual hosts
          1. How to do it…
          2. How it works…
          3. There's more…
        5. Managing MySQL
          1. How to do it…
          2. How it works…
          3. There's more...
            1. Creating MySQL databases
        6. Managing Ruby
          1. How to do it...
          2. How it works...
            1. ruby-build
            2. rbenv
          3. There's more...
      14. 7. Servers and Cloud Infrastructure
        1. Introduction
        2. Building high-availability services using Heartbeat
          1. Getting ready...
          2. How to do it…
          3. How it works…
          4. There's more…
        3. Managing NFS servers and file shares
          1. How to do it…
          2. How it works…
        4. Using HAProxy to load-balance multiple web servers
          1. How to do it…
          2. How it works…
          3. There's more…
        5. Managing firewalls with iptables
          1. Getting ready…
          2. How to do it…
          3. How it works…
          4. There's more…
        6. Managing EC2 instances
          1. Getting ready…
          2. How to do it…
          3. How it works…
          4. There's more...
        7. Managing virtual machines with Vagrant
          1. Getting ready…
          2. How to do it...
          3. How it works…
          4. There's more…
      15. 8. 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. Importing configuration data with Hiera
          1. Getting ready…
          2. How to do it…
          3. How it works…
          4. There's more…
            1. Setting node-specific data with Hiera
            2. Looking up data with Hiera
          5. See also
        6. 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
        7. Generating manifests with puppet resource
          1. How to do it…
          2. There's more…
        8. Generating manifests with other tools
          1. Getting ready...
          2. How to do it...
          3. There's more...
            1. Playing with Pysa
            2. Conclusion
        9. Testing your manifests with rspec-puppet
          1. Getting ready...
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        10. Using public modules
          1. How to do it…
          2. How it works…
          3. There's more…
        11. Using an external node classifier
          1. Getting ready...
          2. How to do it…
          3. How it works…
          4. There's more…
          5. See also
        12. Creating your own resource types
          1. How to do it…
          2. How it works…
          3. There's more…
            1. Documentation
            2. Validation
        13. Creating your own providers
          1. How to do it…
          2. How it works…
          3. There's more…
        14. Creating your own functions
          1. How to do it...
          2. How it works...
          3. There's more...
      16. 9. Monitoring, Reporting, and Troubleshooting
        1. Introduction
        2. Doing a dry run
          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. Checking when a resource is applied
        5. Generating reports
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        6. Producing automatic HTML documentation
          1. How to do it…
          2. How it works…
          3. There's more…
          4. See also
        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
      17. Index