1. Home
  2. Training Library
  3. DevOps
  4. Courses
  5. Getting Started with Puppet

Using Modules

Developed with


Installing Puppet
PREVIEW13m 45s
The Basics
12m 11s
Puppet Language Essentials
6m 25s

The course is part of this learning path

Start course
1h 14m

Puppet is an IT automation system. If you need to install, configure, and update servers, then Puppet can help you tremendously. Instead of doing all of these tasks manually, you can tell Puppet to configure your servers for you.

Not only will Puppet free you from the drudgery of repetitive tasks, but you will also gain major benefits, such as consistency, reliability, speed of deployment, ease of recovery, and scalability.

Do you often have slightly different configurations on servers that are supposed to be identical? With Puppet, you’ll no longer have to figure out why something works on one server but doesn’t work on another one because Puppet will configure them in the same way. You’ll also have less downtime because there is less that can go wrong when everything is configured the way it’s supposed to be.

Do you always seem to be adding more servers? Provisioning servers is a breeze when Puppet already knows how to configure them.

This course will get you started on bringing these benefits to your network. It’s a hands-on course with exercises every step of the way to give you experience using Puppet. First, I will show you how to install Puppet on a virtual machine on your own desktop. Then you will use it as a test environment to learn how to write Puppet code to automate server configuration.

Learning Objectives

  • Install Puppet server
  • Use pre-built Puppet modules
  • Use manifests, classes, resources, facts, nodes, and templates
  • Create your own Puppet modules



We're going to start with a very simple configuration item for Puppet to manage. Suppose you want to set up a message of the day file on a bunch of your servers without having to update them all manually. I'll show you how to configure Puppet to do this on our test VM. And later on, I'll show you how to apply this sort of configuration to more than one server.

One of the great things about Puppet, is that there is a large community of people who write Puppet modules to preform specific tasks, and then make those modules freely available for anyone to use. So whenever you want to do something new with Puppet, you should first see if someone has already written a module to do it so you don't have to. Not only will this save you time, but chances are that the module has already been well tested, so you won't need to do much if any debugging. Furthermore these free modules are typically updated over time, so you don't even need to maintain them yourself as new releases of things like operating systems and applications come out.

The Puppet Forge is the place to look for free modules. Go to forge.puppet.com in your browser. Now search for "motd" to see if there are any modules that take care of the message of the day file. Thankfully, there is one provided by Puppet Labs itself, which is the company behind Puppet. It also says that it's supported, which is great. You can see that there are also other motd modules, but lets stick with the supported one.

Click on the motd link next to Puppet Labs. Note that if you click on Puppet Labs, then it will take you to the wrong place. So make sure you click on the module name.

You'll notice that it shows you a couple lines of Puppet code that will let you use it. Right here. And if you scroll down, you can see more detailed information on how to use the module. The two lines at the top show you two different ways of using the module. The first way is if you want to automatically install this module on your own Puppet server the first time it's used. The second way is if you want to install the module manually. We're going to use the second method.

Copy the command and paste it into your terminal. You don't actually have to include the version because it will just install the latest version if you leave it out. But since we're copying the line from the browser, it doesn't require any extra typing, so why not.

It downloads the module from the forge. Then it installs the module and shows you where it put it, as well as the supporting modules it installed.

I'll show you the simplest way to use our newly installed module. You wouldn't normally do this in production, but it's a nice way to run a quick test. We're going to use the Puppet Apply command, which runs Puppet only on the current host and only with the given Puppet code.

The first option is --noop, which means no operation. In other words, don't actually run this for real, but show us what would have happened if we did run it for real. It's always a good idea to use noop first when you're testing some new Puppet code.

The next flag is -e, which says to execute the following code. If you don't use the -e flag, then you have to give it the name of a file containing the code. When you use the -e flag, the code needs to be in quotes. Type, "include motd" in quotes.

The output may not seem very helpful at first, but what it's saying is that the etc/motd file is absent or missing. And that it would create that file if you ran this command without noop. Just to verify that what it's saying is true, let's see if the etc/motd file exists. It is indeed missing.

Now hit the up arrow twice to bring back the previous Puppet Apply command. And remove the noop option so it will run the command for real.

Now let's see if it created the motd file. It did. Let's look at what content it put in the file. Great. That's the default content set by the motd module.

Of course, to truly see the message of the day, we need to log in again. So let's do that. You can see that Ubuntu prints a bunch of other information first, and then it prints the message of the day, which is indeed what we put in the etc/motd file. Now we'll drop back to our original shell by hitting Control+D. That's it for this lesson.

About the Author
Guy Hummel
Azure and Google Cloud Content Lead
Learning Paths

Guy launched his first training website in 1995 and he's been helping people learn IT technologies ever since. He has been a sysadmin, instructor, sales engineer, IT manager, and entrepreneur. In his most recent venture, he founded and led a cloud-based training infrastructure company that provided virtual labs for some of the largest software vendors in the world. Guy’s passion is making complex technology easy to understand. His activities outside of work have included riding an elephant and skydiving (although not at the same time).

Covered Topics