Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Puppet 3 Cookbook

You're reading from   Puppet 3 Cookbook 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

Arrow left icon
Product type Paperback
Published in Aug 2013
Publisher Packt
ISBN-13 9781782169765
Length 274 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
John Arundel John Arundel
Author Profile Icon John Arundel
John Arundel
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Puppet 3 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Puppet Infrastructure 2. Puppet Language and Style FREE CHAPTER 3. Writing Better Manifests 4. Working with Files and Packages 5. Users and Virtual Resources 6. Applications 7. Servers and Cloud Infrastructure 8. External Tools and the Puppet Ecosystem 9. Monitoring, Reporting, and Troubleshooting Index

Preface

A revolution is underway in the field of IT operations. The new generation of configuration management tools can build servers in seconds and automate your entire network. Tools such as Puppet are essential to take full advantage of the power of cloud computing, and build reliable, scalable, secure, high-performance systems.

This book takes you beyond the basics and explores 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 complete code samples for every recipe.

It takes the reader from rudimentary knowledge of Puppet to a more 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.

This book also includes real examples from production systems and techniques that are in use in some of the world's largest Puppet installations. It will show you different ways to do things using Puppet and point out some of the pros and cons of these approaches.

The book is structured so that you can dip in at any point and try out a recipe without having to work your way through from cover to cover. You'll find links and references to more information on every topic, so that you can explore further for yourself. Whatever your level of Puppet experience, there's something for you, from simple workflow tips to advanced, high-performance Puppet architectures.

I've tried hard to write the kind of book that would be useful to me in my day-to-day work as a devops consultant. I hope it will inspire you to learn, to experiment, and to come up with your own new ideas in this exciting and fast-moving field.

What this book covers

You'll find the following chapters in this book:

Chapter 1, Puppet Infrastructure, shows how to set up Puppet for the first time, including instructions on installing Puppet, creating your first manifests, using version control with Puppet, building a distributed Puppet architecture based on Git, writing a script to apply Puppet manifests, running Puppet automatically, using Rake to bootstrap machines and deploy changes, and using Git hooks to automatically syntax-check your manifests.

Chapter 2, Puppet Language and Style, covers aspects of writing good Puppet code, including using Puppet community style, checking your manifests with puppet-lint, structuring your manifests with modules, using standard naming and style conventions, using inline templates, using iteration, conditional statements, and regular expressions, using selectors and case statements, and string operations.

Chapter 3, Writing Better Manifests, goes into detail on specific features of Puppet that you can use to improve your code quality and usability, including arrays, definitions, ordering your resources with dependencies, inheriting from nodes and classes, passing parameters to classes, overriding parameters, reading information from the environment, writing reusable manifests, and using tags and run stages.

Chapter 4, Working with Files and Packages, deals with some of the most common sysadmin tasks, including managing config files, using Augeas, generating files from snippets and templates, managing third-party package repositories, using GnuPG to encrypt secret data in Puppet, and building packages from source.

Chapter 5, Users and Virtual Resources, explains what virtual resources are and how they can help you manage different combinations of users and packages on different machines, and shows you how to use Puppet's resource scheduling and auditing features.

Chapter 6, Applications, focuses on some specific applications that you may need to manage with Puppet, including complete recipes for Apache and Nginx, MySQL, and Ruby.

Chapter 7, Servers and Cloud Infrastructure, extends the power of Puppet to manage virtual machines, both on the cloud and on your desktop, with recipes for Vagrant and EC2 instances. It also shows you how to set up load balancing with HAProxy, firewalls with iptables, network filesystems with NFS, and high-availability services with Heartbeat.

Chapter 8, External Tools and the Puppet Ecosystem, looks at some of the tools that have grown up around Puppet, including Hiera, Facter, and rspec-puppet. It also introduces you to some advanced topics including writing your own resource types, providers, and external node classifiers.

Chapter 9, Monitoring, Reporting, and Troubleshooting, covers ways that Puppet can report information about what it's doing, and the status of your system. This includes reports, log, and debug messages, dependency graphing, testing and dry-running your manifests, and a guide to some of Puppet's more common error messages.

What you need for this book

To run the examples in this book, you will need a computer with Ubuntu Linux 12.04 and an Internet connection.

Who this book is for

The book assumes that the reader has a little experience of Linux systems administration, including familiarity with the command line, file system, and text editing. No programming experience is required.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "You can check your manifests for style guide compliance using the puppet-lint tool."

A block of code is set as follows:

node 'cookbook' {
  cron { 'randomised cron job':
    command => '/bin/echo Hello, world >>/tmp/hello.txt',
    hour    => '*',
    minute  => random_minute(),
  }
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

newparam(:path) do
  validate do |value|
    basepath = File.dirname(value)
    unless File.directory?(basepath)
      raise ArgumentError , "The path %s doesn't exist" % basepath
    end
  end
end

Any command-line input or output is written as follows:

ubuntu@cookbook:~/puppet$ papply
Notice: Hello, I was included by your ENC!
Notice: /Stage[main]/Admin::Helloenc/Notify[Hello, I was included by your ENC!]/message: defined 'message' as 'Hello, I was included by your ENC!'
Notice: Finished catalog run in 0.29 seconds

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking the Next button moves you to the next screen".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime