The Tools for Learning Puppet: CLI, VIM, GIT (OMG, WTF, BBQ)

This is the introductory piece in a tutorial series that includes three more tutorials for learning command line interface (CLI), vim and Git.

Puppet has its roots in the open source software world, which leans towards interacting with the computer through the command line interface (CLI), rather than through a graphical user interface (GUI). Getting your hands around the Linux-ey tools you need to work with Puppet can make you want to flip tables at first, especially when the instructions assume you know something you don't — for example, if the guide uses the word directory to refer to something you think of as a folder.

People who want to learn Puppet come from all kinds of backgrounds, and this blog post is here to help you get familiar with fundamental tools commonly used in system administration and other technical fields. Once you get a handle on CLI, Vim and Git, you'll feel a lot more confident going through a Puppet Fundamentals course.

UNIX: where there’s a shell, there’s a way

The Linux-y / Unix-y basics needed for a Puppet Fundamentals class (and in general for maneuvering around in the dark, sticky bits of your computer) are a command line interface, a text editor, and a version control system. In this post, I'll provide a quick overview of what the tools do, and the steps needed to install what is basically a tiny computer on your computer, so your cat and I can look at the same screens.

A Quick Overview: CLI / Terminal

If you come from a Windows background, you are used to getting to the files you want by going to your desktop, selecting a folder, selecting some number of sub-folders, and then clicking open your file so you can get work done.

picture of a folder named “Useful Things” (Actual folder on my desktop)

Back before folks had figured out how to make a mouse- and icon-based interface — called a Graphical User Interface, or GUI (pronounced “gooey”) — you had to talk directly to the computer with your keyboard. Command Line Interface (CLI, or just “command line”) is the language you use to communicate with the computer. You can think of the command line terminal as a chat room for you and your computer.

A programmer writes up a program and saves it in a file. They then tell the terminal to run the file they have saved, and watch the terminal to make sure the program runs as planned.

Operations folks use command line to explore what is going on inside the computer, to make sure that the computer is working as planned.

A Quick Overview: Vim / Text Editor

On any computer you plan to use for programming, you are going to need a text editor. The reason you shouldn’t use Word (or anything that you would usually use for typing up a document) is that those programs actually put invisible code around the words you type so you can format your text to look pretty. That invisible code will get jumbled up with the code you are trying to write, and then you will have a Bad Time. While technically you could use Notepad, we are going to work with vim, a popular open source text editor. Vim looks weird at first, but it’s a pro-level tool that will save you time and clicks in the long run. Also, it’s what we use in Puppet Fundamentals, so being familiar with vim will help you when you start learning Puppet.

Instead of having a graphical interface (clicking icons to open a menu and selecting from there), vim uses a text interface. While this means you will ultimately save a lot of time by not having to move your hand to your mouse constantly, it does mean you will need to memorize some keyboard shortcuts to make things happen.

We will download a tool called a "virtual machine" that already has vim installed, but if you want to add vim to your home computer, go to http://www.vim.org/download.php for installation instructions.

A Quick Overview: Git / Versioning Control

Since we want to be able to share our code, and use the code from any computer — even if our laptops mysteriously combust — we are going to use Git. Git basically keeps track of all of the changes you make to your files. You can even have several different copies of the main file (called “branches”), make different changes to each of those branches, then merge them all back together seamlessly into the original file (called a repository, or a “repo”).

GitHub is a website that runs Git, and it’s a place where you can write or upload code and choose to open it up for anyone to use or contribute to. If someone wants to make a change that would affect your original, they make a “pull request.” You then review their changes and decide whether or not to merge their code into your repo. Part of me hates me for saying this, but GitHub is kinda like Facebook for code. You can create your own GitHub account at https://github.com.

Get the Tools Ready

All right, let’s get ready to play. You’re going to need a computer that uses a terminal, and in order to follow along, we should be looking at the same kind of terminal. Since I can’t be in the same room with you, we will download a “virtual machine” (VM).

A VM is like a small section of your computer that thinks it is an entirely separate computer (and it basically is). You could install a Windows VM on your Mac, or a Mac VM on your Unix box; if you really wanted to, you could could even install a VM on your VM, so you could have a Linux VM on your Unix VM while you work on your laptop.

picture of Xibit saying “I heard you like computers, so we put a computer on your computer, so you can compute while you’re computing”

VirtualBox is free software that allows your computer to host a VM. Head to https://www.virtualbox.org/wiki/Downloads and download the version for your operating system (Windows, OS X, Linux, or Solaris). Open it and install as you are prompted.

Now that your computer can host VMs, let’s add one! We’ve got some VMs ready to roll at http://puppetlabs.com/download-learning-vm. Select the green button with “OVF Version” on it. Downloading the VM will take a while, so I would recommend being on a wired internet connection (not wi-fi), and petting your cat while saying encouraging things. Once the VM has downloaded, unzip the file. (If you need help unzipping a file, check out this page.)

Open up VirtualBox and at the top menu, select File > Import Appliance. Select the learn_puppet file that ends in .ovf (it stands for Open Virtualization Format). Once that file finishes loading, an Appliance Settings window will appear; just click Import at the bottom.

Now select the green arrow at the top that says Start.

OMG! WAT?!

OK; maybe instead of jumping right in there, we should have warned you about what is going on, particularly regarding mouse and keyboard capture. A lot of things are happening at once. Let them happen, and read on. That black window that just appeared out of nowhere? That’s the VM. All the white text going on in the main screen is the VM booting up. All the semi-transparent text windows that are popping up are not happening in the VM: They are notifications from your computer about what is going on. You can click to expand and read these notifications, click X to make them go away, or click the “no speech bubbles” icon to never see that warning again.

When you click inside the black box, it “captures” your mouse — kinda like sucking it through a computer wormhole. You won’t be able to click out or mess with your laptop until you jump back through that wormhole. There will be a notification the first time you try to click, and it will give you the escape command to send your mouse through the wormhole. Don’t worry if you forget it — you’ll see there’s a reminder note at the bottom right corner of the VM window. Note for Mac users: When you see Left Command, that means the command key on the left side of the keyboard, not “cmd + left arrow.”

Once the loading bar has finished and all the text has steadied, hit “enter.” When you are asked for a login, type root, and when it asks for a password, type puppet.

Congratulations! You’re in!

But in where, exactly? You start off in what is called your “home directory,” which is basically the biggest folder for the login you’ve used. You logged in as an administrator — that’s what “root” means in this case — so you can now check out any of the folders and files inside your home directory. You can also see all of the user logins on this computer, and make changes to other users’ files. If you had logged in as a non-root user, you wouldn’t have that magnificent and terrifying power.

You will now see [root@learn ~:master +-]#
This is called a prompt, and it indicates that you are logged in as root@learn, and that you are currently in the home directory (~ is shorthand for home directory). When you see the hashtag (#), the computer is waiting for you to tell it to do something (in other terminals, you may see > or $ instead of the hashtag).

The next steps are telling the computer to do something, learning how to move around and how you can wreak havoc on your computer using command line. All of this will be covered in the next blog post! See you there!

##Resources

Tiffany Longworth is a business systems analyst at Puppet Labs.

##Learn More

  • The command line interface is a powerful way to interact with your computer, but not intuitively obvious if you're coming from a non-Unix, non-Linux background. Read Tiffany's tutorial.
  • Learn to use vim, a popular text editing program, another Tiffany Longworth-authored tutorial.
  • And last but not least in this tutorial series, learn to use Git, a popular version control system.
  • There are many Puppet modules for managing your most basic tasks. Read about supported modules and how they can make your job easier.
  • Read about the new features in Puppet Enterprise, including access for more users in your organization.
  • If you're looking for enterprise-level configuration management software that's fully tested, scalable and fully supported, you can download and try out Puppet Enterprise for free.
Puppet sites use proprietary and third-party cookies. By using our sites, you agree to our cookie policy.