Now we're going to begin our journey into persistent
configuration with Puppet, and this can be done through modules
and manifests. At the very basis of our persistent Puppet
configuration, we have our manifest files,
the .pp files. More complex configuration is really a collection of
manifests, and they're stored within a module.
There are public modules available that we can download from the
Puppet Forge, and this is what we're going to look at first
because it can get us up and running very quickly. Let's say that
we wanted to install Apache.
We could go through and look at the current modules that we have.
If we don't have the Apache module,
we can then go through and install it. Installing it into the directory
/usr/share/puppet/modules will make it available to all users.
Once we're ready with that,
we can then simply do a puppet apply ‑e, or include it within one of our
other manifests, and include the module name Apache.
So this is what we're going to take a look at now.
We're going to look at working with our modules,
seeing how we can get our Apache Web Server up and running very quickly.
We'll list our modules and install our modules and
include then the module for execution.
So here we are at our command line.
And you can see I'm still logged in as root.
I can go through and run our puppet and module list.
We've only just installed Puppet, so I wouldn't expect any modules to be here.
But if I go through and list anyway, and I can make sure
that if we've got warning messages,
they are sent to the dev/null, and we can see then that we're
looking at /usr/share/puppet/modules. For a standard user, you
can also look in your home directory,
but we can see we don't have any modules installed.
And we're going to change this.
We can research modules that are available from
forge.puppet.com, but if you know which module you want,
we can go ahead and run a module install. We can specify the path,
though I want to make sure it does go into the shared directory so this
is then available for other users as well.
And let's just move this to the top of the screen for readability and then
add in puppetlabs as the author, and then the module name,
which is apache. I say you can research that, though, from forge.puppet.com,
but we then can download it, and then all of the code is already
built for us across a wide range of machines,
not just the machine that we've downloaded on.
So ideally we download the module onto our Puppet server and then we
can execute code for all of our agent machines.
It's also downloaded dependency modules.
A very important one there is the standard library from puppetlabs
because that has many very useful resources that we can make use of.
Having downloaded our module and the prewritten code,
we're ready to execute it.
So again, we're going to use the same syntax as we did before,
so the puppet apply, a ‑e. But we can also run this from within a manifest,
but it's very much more simple now, it's simply include and then the module name.
Again, if we don't want to see any of the spurious output,
we can go through and redirect our error messages through to /dev/null,
hit the big Enter key, and away we go.
The first thing that happens is we compile a catalog of the
tasks that are necessary, and we should see that coming up
on the screen quite quickly.
The agent then executes their catalog, and again,
we'll see the output from the execution on the screen,
showing me all of the tasks that have been completed.
So as we go through and take a look at the output,
then we can see there is a lot that it will have done. It will
have applied the default settings for the module,
although we could make it more complex by specifying more properties.
But in essence,
if we go through and take a look now, we're listening on port 80, our web
server is up and running, and that would have been across distributions
as well. And if I look then at connecting through, our default page is
now showing being the Ubuntu page,
but you can be certain that this module would work across a range of different Linux distributions without you having to code anything.