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

Installing Puppet

Developed with
Puppet

The course is part of this learning path

Cloud Configuration Management Tools with Ansible, Puppet, and Chef
course-steps 4 certification 1 lab-steps 2 quiz-steps 1

Contents

keyboard_tab
Introduction
Installation
The Basics
6
Resources12m 11s
Puppet Language Essentials
8
Templates6m 25s
Wrap-up
play-arrow
Start course
Overview
DifficultyBeginner
Duration1h 14m
Students646

Description

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

 

Transcript

Throughout this course, I will be using a locally installed virtual machine to show you how to use Puppet. Since Puppet is most often used in Linux environments, we'll be running it on Linux in this course. To get the most out of this course, I recommend that you install a Linux virtual machine on your own computer as well and perform the same steps that you see in the videos. It's not a requirement, but I definitely recommend it.

There are numerous benefits to using a VM when you're learning Puppet. First, if you don't have a spare Linux machine kicking around, then you won't have to turn your desktop into a duel boot system. Second, you won't have to worry about accidentally wreaking havoc on your own system because you will only be running system inside the virtual machine. Third, if you're about to try something that might be hard to undo, then you can take a snapshot of your VM and revert back to that snapshot if you need to. And finally, if you need to test Puppet on multiple systems, then you can just create one or more additional VMs.

First, we need to install VirtualBox, which is a free virtualization platform that runs on Windows, MacOS, and Linux. I'm going to install it on my Mac, but the process is similar on Windows. If you're running Linux, then the installation procedure is much more complicated, so you should follow the installation steps on the VirtualBox website.

Go to VirtualBox.org and download the latest version. I don't think they could have made the download button any bigger. Now click on the link for your desktop's operating system.

When the file is finished downloading, click on it. Just has to verify it first. All right, that opens a window. Double-click on the installer file. All right, it's just verifying it. Click continue, click continue, and you can change the install location if you want, but we'll just go with the default, click install, put in my password. All right, and that's it. Just click close. We'll move the installer to the trash. On a Mac, the VirtualBox icon will be in the applications folder in the finder. On Windows, it will be on your desktop. Let's just close this window.

Now that we have VirtualBox installed, we could install Linux on the VM from scratch, but a much easier way is to use Vagrant. So go to vagrantup.com. And click download. Now choose your operating system. When the file is done downloading, click on it and start the installer. Now double-click the installer icon. Click continue. Again, you can change the installation location, but we're going to use the default, so just click install. Put in my password. And that's it, click close. Move the installer to the trash. And we'll close this window.

Now to create a VM running Ubuntu 14.04, which is an easy version of Linux to use, you can just go to a command line. And type vagrant init ubuntu slash trusty64. We just need to make one small change. Edit vagrant file, which will be in the directory where you ran the vagrant init command. Scroll down until you see the line that says vb.memory equals 1024. There it is. Remove the pound sign so this is no longer a comment. We're doing this because the default memory size is 512 megabytes, but we need at least one gigabyte to run Puppet server. You also need to uncomment the config.vm.provider virtualbox line above it. And the end line below it. All right, so just save the file. And exit. And now type vagrant up. It will take a little while to download the OS, get it installed, and boot the VM, but it was fairly painless to get it running, wasn't it? I'm just going to skip ahead so you don't have to watch it download.

Now for the slightly more difficult part, installing Puppet. First, let's access the VM using SSH so we don't have to use the VM console in VirtualBox. On a Mac or on Linux, you can just do this from the command line. On Windows, it's probably easiest to use Putty. Note that the VM has the SSH port forwarded to 2222, so you need to connect using SSH minus P 2222 vagrant@localhost. All right, since this is the first time connecting to this VM, it's going to ask us a security question, so just say yes to this. All right, now it's asking for vagrant's password, which is also vagrant. And we're in.

Now on a production system, you would likely log in as a regular user and then use the pseudo command whenever you need to run a super user level command, but since we're just running this on a local desktop, I'm going to switch user to root. The password is vagrant for the root user as well.

Since Ubuntu doesn't know where to get Puppet packages from, we need to get the Puppet package that will tell it where to look. First, use wget to grab the package. Wget https://apt.puppetlabs.com/ puppetlabs-release-pc1-trusty.deb. Okay, then install the package with the d package command. That's dpkg minus i puppetlabs. Now here you can just hit the tab key and it will fill in the rest for you. This just updated our list of repositories. So now we need to do an apt get update to add the puppet packages to its list of available packages. This will take about 30 seconds, so I'll just skip ahead. Now we can install Puppet server. Do an apt get install, puppetserver. And just hit enter. This will take a couple of minutes so I'll skip ahead again.

By the way, this command installs the latest version of the Puppet server, so you will likely be installing a later version than the one I'm installing in this video, and that means there's a good chance that you will get slightly difference output during some of the exercises in this course than what I show on my videos. The differences shouldn't be significant though. There are a couple more things we need to do before we start the server. First, we need to change its memory settings because we're running Puppet server on a small VM instead of a production system. So edit etc default puppetserver using the editor of your choice, such as VI, Nano, or Emacs. Although if you want to use Emacs, you'll have to install it because it's not included in Ubuntu. I'm going to use VI which actually runs Vim, a nicer version of VI. If you're not familiar with VI, it can take a while to get used to it, but it does have the advantage that it understands code. So for example, it puts comments and strings in difference colors as you can see here. If you would prefer an editor that's easier to use, then try Nano.

Now, go to the JAVA_ARGS line. In the two places where it says 2g, that is two gig, change it to 512m, that is 512 meg. Okay, now save the file.

Next, we need to give the system a host name alias of Puppet because that's the default server name that the Puppet agent looks for when it tries to connect to the Puppet server. We also need to set its full host name to the puppet.test.vm so that it has a fully qualified domain name. So edit etc hosts and add puppet.test.vm. And puppet just before localhost. Save the file. Now edit etc host name. And we're just going to replace this entirely with puppet.test.vm. Now we're on host name puppet.test.vm so we don't have to reboot to make the host name change take effect.

Now we can start Puppet server. We'll use the restart option because it's more likely to let us know if there's a problem.

It will take a minute or so for the Puppet server to start, so I'm just going to skip ahead and also clear the terminal window. Even though the Puppet server is running now, we need to do one more thing before we can run our first Puppet command. We need to get Puppet into our path.

When we installed the Puppet server, it updated the default path for us, but our current shell is still using the old path. There are a few ways to get the new path, but one of the easiest is to just exit the shell and start the shell again so it will pick up the new path. Hit Control + D or type exit, and then type su dash again.

Just to make sure that Puppet is in our path now, let's type which puppet. Great, it knows where it is.

Now for our first Puppet command, we're going to make sure that the Puppet server is always running. Here's the command to do that. Puppet resource service puppetserver ensure equals running enable equals true. You'll learn more about the difference parts of this command later on in the course. All right, it might not be easy to tell, but this is actually showing that the command succeeded.

And finally, we need to enter one more Puppet command. Although we want to make sure that the Puppet server is always running, we need to make sure that the Puppet agent isn't running. That's because we'll be running it manually to test our code, so we don't want the Puppet agent to run on its own and potentially interfere with our manual test runs.

Hit the up arrow to bring back the last command and modify instead of typing it all again. Change puppetserver to puppet, which is the name of the Puppet agent service. Change running to stopped. And change true to false.

That ensured that the Puppet agent is stopped and it disabled it so it won't run when you reboot the VM.

Okay, our test environment is all ready to go, so let's get started.

About the Author

Students12788
Courses41
Learning paths20

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