Instructor: 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.