puppet beginners guide
Those nice people at Packt Publishing have asked me to write a follow-up to the surprisingly successful Puppet Cookbook. This book, the Puppet 3 Beginner’s Guide caters for those who are completely new to Puppet, and takes you through installation, setup, writing your first manifests, using Git to manage and distribute your manifests, managing users, reporting and troubleshooting, and a few other useful things.
Some of the most respected people working in devops and configuration management have contributed to the book’s development by reading early chapters, giving feedback, testing code, and making suggestions.
What they said
“Well-written… smoothly-structured… John Arundel’s new book is a solid guide to helping you become both a proficient Puppet user and a more efficient, knowledgeable, and versatile system administrator.”
“I can’t imagine having found anything better. This book avoids the stress and boredom of a slow-paced learning session by diving right in to the most important concepts. It was all I needed to feel confident at work, and it only took an hour before I was writing my own code.”
“John Arundel is both a superb engineer and just as importantly an excellent teacher/communicator. Currently the best Puppet book available and essential for anyone wanting to learn Puppet.”
— Amazon.com (Kindle edition)
Introduction to Puppet
What’s the problem with computers?
In this chapter you’ll learn what Puppet is, and what it can help you do. Whether you’re a system administrator, a developer who needs to fix servers from time to time, or just someone who’s annoyed at how long it takes to set up a new laptop, you’ll have come across the kind of problems Puppet is designed to solve.
- What is configuration management?
- What problems is Puppet trying to solve?
- How do you work differently as a systems administrator using Puppet?
First steps with Puppet
In this chapter you’ll learn how to install Puppet, how to write your first manifest, and how to put Puppet to work configuring a server. You’ll also understand how Puppet reads and applies a manifest.
- Installing Puppet
- Creating your first manifest
- Making your first changes on a machine with Puppet
Packages, files, and services
The most common types of resources you’ll manage with Puppet are packages, files, and services. They often occur together, with a package providing a service, and the service requiring a configuration file. In this chapter you’ll see how to use Puppet to manage these resources effectively.
- Managing packages
- Managing services
- Resource dependencies
- Managing config files
- The package - file - service pattern
- A complete worked example using Nginx and a simple website
Managing Puppet with Git
In this chapter you’ll learn how to use the Git version control system to manage your Puppet manifests. I’ll also show you how to use Git to distribute the manifests to multiple machines, so that you can start managing your whole network with Puppet.
- Introduction to Git
- Using Git to version control your Puppet code
- Committing changes
- Looking at revision history
- Reverting changes
- Merging commits
- Using Git to deploy Puppet manifests to multiple servers
- Setting up remote access to Git
- Pulling updates and running Puppet from cron
- Using feature branches
In this chapter you’ll learn how to use Puppet to create and manage user accounts, configure SSH access and keys, and control user privileges via sudo.
- Creating user accounts with Puppet
- Configuring SSH
- Distributing SSH keys
- Controlling sudo privileges
- Locking and removing user accounts.
Tasks and templates
In this chapter you’ll learn how to use Puppet’s resource types to run commands, schedule regular tasks, and distribute large trees of files. You’ll also find out how to insert values dynamically into files using templates.
- Using exec resources to run commands
- Using cron resources to run scheduled jobs
- Deploying trees of files
- Using templates
Definitions and classes
In this chapter you’ll learn how to group resources into reusable clumps that you can refer to by name, making it easy to create lots of similar resources at once. You can also make your Puppet manifests shorter, neater, and more readable by eliminating duplicated code.
Expressions and logic
In this chapter you’ll learn how to make choices in your Puppet manifests, how to do arithmetic, logic, and string operations in the Puppet language, and how to use regular expressions to match patterns in strings. You’ll also find out about some useful Puppet data types: arrays and hashes.
- If statements
- Case statements
- Regular expressions
- Capture variables
- Regular expression substitutions
- Arrays and hashes
- Multi-level hashes
Reporting and troubleshooting
In this chapter you’ll learn how to get information on what Puppet’s doing, when it runs, the changes it makes, how to monitor Puppet, and what to do about many common errors you may encounter.
- Dry-run mode
- Debug mode
- Printing messages
- Exec output
- Monitoring Puppet
- Causes of Puppet run failures
- Common Puppet errors and how to fix them
Moving on up
In this chapter you’ll learn some simple principles for writing better Puppet manifests, including style and code layout. You’ll also find out what resources are available for learning more about Puppet, and get some ideas for more advanced projects to build your Puppet knowledge and improve your infrastructure.
- Style guidelines
- Module design
- Learning more
- Project ideas
The Puppet 3 Beginner’s Guide is available on Amazon or via the publisher: