Build reliable, scalable, secure, and high-performance systems to fully utilize the power of cloud computing.
Over 4,000 copies sold
Get ready for Puppet 3
The Puppet 3 Cookbook is 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. If you enjoyed the Puppet 3 Beginners Guide, or if you’re an experienced Puppet user already, the Puppet 3 Cookbook is the book to take your Puppet knowledge to the next level.
Shows you how to use Puppet 3 to take control of your servers and desktops, with detailed step-by-step instructions
Written in a simple, practical style by a professional systems administrator and Puppet expert, every recipe has detailed step-by-step instructions showing you the exact commands and configuration settings you need.
Packed with tips and inspiring ideas for using Puppet to automate server builds, deployments, and workflows.
Covers all the popular tools and frameworks used with Puppet: Hiera, RSpec, puppet-lint, and more
Teaches you how to extend Puppet with custom functions, types, and providers.
What they said
Reviews of the first edition:
What’s in it
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 how to extend Puppet by adding your own providers and resources. It starts with help on how to set up and expand your Puppet infrastructure, 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. 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 Ruby applications and MySQL databases, building web servers, load balancers, high-availability systems with Heartbeat, and many other state-of-the-art techniques.
More and more systems administration and IT jobs require some knowledge of configuration management, and specifically Puppet. The Puppet 3 Cookbook not only gives you everything you need to become a Puppet expert, but includes powerful code samples and techniques developed over many years of production experience. With it, you’ll save time and effort by automating tedious manual processes, impress your boss by delivering better business value from IT, and future-proof your career by getting to grips with the new technologies revolutionizing the industry.
What you’ll learn
- Installing and setting up Puppet for the first time
- Producing eye-catching reports and information for management
- Understanding common error messages and troubleshooting common problems
- Managing large networks
- Taking control of configuration data with Hiera and encrypting secrets with GnuPG
- Producing reliable, clean, maintainable code to community standards with puppet-lint and rspec-puppet
- Using classes and inheritance to write powerful Puppet code
- Deploying configuration files and templates for lightning-fast installations
- Using virtual machines to build test and staging environments, and production systems on cloud platforms such as EC2
- Automating every aspect of your systems including provisioning, deployment and change management
- Making Puppet reliable, performant, and scalable
Who the book is for
The book is for anyone who builds and administers servers, especially in a web operations context. It requires some experience of Linux systems administration, including familiarity with the command line, file system, and text editing. No programming experience is required.
Buy the Puppet 3 Cookbook
- Buy Puppet 3 Cookbook (Kindle edition) now on Amazon.co.uk
- Buy Puppet 3 Cookbook (paperback) now on Amazon.com
- Buy Puppet 3 Cookbook (Kindle) now on Amazon.com
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:
John Arundel is a consultant sysadmin and devops expert of 20 years experience. He is the author of The Puppet 3 Cookbook, The Puppet 3 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. John also regularly regales his 10,000+ Twitter followers with deep thoughts about computing, configuration management, and software development at @bitfield.
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.
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.
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.