Puppet 3 Beginner's Guide - out now

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 take 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.
Buy the Puppet 3 Beginner’s Guide on Amazon.com (Kindle edition
)
Buy the Puppet 3 Beginner’s Guide on Amazon.co.uk (Kindle edition
)
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.
Outline
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
Managing users
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.
- Arrays
- Definitions
- Parameters
- Classes
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
- Selectors
- Operators
- 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.
- Summaries
- Reports
- 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:
Buy the Puppet 3 Beginner’s Guide on Amazon.com (Kindle edition
)
Buy the Puppet 3 Beginner’s Guide on Amazon.co.uk (Kindle edition
)
About Bitfield Consulting

John Arundel is an infrastructure and devops consultant of 20 years experience. He is the author of The Puppet Cookbook, The Puppet Beginner’s Guide and other technical books, a well-known expert on Puppet, the open-source configuration management system, and speaks regularly at technical user groups and conferences.
He works closely with a small group of selected clients around the world to develop and support:
- Scalable, reliable, performant infrastructure
- Systems automation with Puppet
- Devops tools, practices and culture
- Continuous integration, testing, and deployment
- Monitoring, reporting, and performance analysis
- Big data
- Virtualization and cloud infrastructure
Some of the technologies Bitfield Consulting works with: Puppet, EC2, Hadoop, HBase, Rails, Icinga, Xen, Vagrant, Redis, Clojure, Git, MySQL, RDS, PostgreSQL, HAProxy.
Let’s talk
Could Bitfield Consulting help you? Email John at hello@bitfieldconsulting.com or message @bitfield on Twitter.
The Puppet Cookbook, 2nd Edition

The successful Puppet Cookbook is now heading for a 2nd Edition, fully updated to cover Puppet 3 and with masses of new material, tips, recipes, ideas, and fully-working example code to help you kick-start your Puppet infrastructure. The book is scheduled for publication in July 2013.
Could you help? Want to get a sneak preview of the book, see early chapters, and help contribute to the book’s development? You could be one of a select group of beta-readers who receive each chapter as it’s written. The price? All you have to do is read the text, try out the examples, and send me your comments, suggestions, and feedback. To apply for the beta-reader programme, email john@bitfieldconsulting.com. I look forward to hearing from you!
Puppet Cookbook author interview
Submitted by John Arundel on Mon, 01/09/2012 - 17:06
You can read an in-depth interview with me about the Puppet 2.7 Cookbook and the writing process over on Packt Publishing’s website. It gives a bit of background about me, some information about what’s in the book, and I describe some tips and advice for other people contemplating writing technical books.
“If just one person is helped and inspired by this book… then I’m not giving refunds to the others.”
I tried to make it a bit more interesting than the usual author interview. You will be the judge of whether I’ve succeeded.
Review: Test-driven Infrastructure with Chef
Submitted by John Arundel on Wed, 10/19/2011 - 19:57
Test-Driven Infrastructure with Chef by Stephen Nelson-Smith
This slim volume is a good introduction to Chef, with sufficient worked examples to get you up and running with a Chef-powered server fairly quickly. However, the author wants to do more than just teach you Chef: he wants to introduce you to a particular way of thinking about infrastructure, “Infrastructure as Code”.
If services are provisioned by programs, then we can - and should - test those programs. Further, we can write them in a test-driven style: start with the description of how the service should behave, and write a test that expresses this. Then write code that makes that test pass.
Nelson-Smith argues that this and other techniques from the school of Agile software development are of great benefit to systems administrators building modern automated infrastructures. He not only makes a convincing case for test-driven infrastructure development, but has provided a helpful tool for doing it, cucumber-chef, which is introduced in the book with a detailed example.
There is a great deal of debate over which is the best configuration management tool. However, it doesn’t matter which tools you use to build a house if the house subsequently falls down. Nelson-Smith gets this point - the book isn’t called “Chef-Driven Infrastructure with Tests”. His message, with which I wholeheartedly agree, is that we should apply to infrastructure code the lessons learned from the last decade of progress in software development. To that end, his book is both timely and important.

