Book Image

Puppet 3: Beginner's Guide

By : John Arundel
Book Image

Puppet 3: Beginner's Guide

By: John Arundel

Overview of this book

<p>Everyone's talking about Puppet, the open-source DevOps technology that lets you automate your server setups and manage websites, databases, and desktops. Puppet can build new servers in seconds, keep your systems constantly up to date, and automate daily maintenance tasks. <br /><br />"Puppet 3 Beginner's Guide" gets you up and running with Puppet straight away, with complete real world examples. Each chapter builds your skills, adding new Puppet features, always with a practical focus. You'll learn everything you need to manage your whole infrastructure with Puppet.<br /><br />"Puppet 3 Beginner’s Guide" takes you from complete beginner to confident Puppet user, through a series of clear, simple examples, with full explanations at every stage.</p> <p>Through a series of worked examples introducing Puppet to a fictional web company, you'll learn how to manage every aspect of your server setup. Switching to Puppet needn't be a big, long-term project; this book will show you how to start by bringing one small part of your systems under Puppet control and, little by little, building to the point where Puppet is managing your whole infrastructure.</p> <p>Presented in an easy-to-read guide to learning Puppet from scratch, this book explains simply and clearly all you need to know to use this essential IT power tool, all the time applying these solutions to real-world scenarios.</p>
Table of Contents (17 chapters)
Puppet 3 Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Your first manifest


To see what Puppet code looks like, and how Puppet makes changes to a machine, we'll create a manifest file and have Puppet apply it.

Create the file site.pp anywhere you like, with the following contents:

file { '/tmp/hello':
  content => "Hello, world\n",
}

How it works

You can probably guess what this manifest will do, but I'll explain the code in detail first.

file { '/tmp/hello':

The word file begins a resource declaration for a file resource. Recall that a resource is some bit of configuration that you want Puppet to manage: for example, a file, user account, or package. A resource declaration looks like this:

RESOURCE { NAME:
  ATTRIBUTE => VALUE,
  ...
}

RESOURCE indicates the type of resource you're declaring; in this case, it's a file.

NAME is a unique identifier that distinguishes this instance of the resource from any other that Puppet knows about. With file resources, it's usual for this to be the full path to the file, in this case, /tmp/hello.

There follows...