Setting Up the Chef Environment with the Right Tools
The course is part of this learning path
In this lesson, we will cover how to get an environment setup that will enable you to get started with Chef. If you are a Ruby developer and already have your preferred setup, then feel free to use it.
We will show you how to use Kitchen with VirtualBox and Vagrant to configure a virtual machine to test from. VirtualBox is a virtualization tool that allows you to host virtual machines. And Vagrant is a virtual machine management tool that allows you download and provision different types of guest operating systems.
You will see how to download and install the tools in the Applications directory.
After those are installed, we will install the Chef development kit. Once it’s complete, we will make sure everything is working by opening a terminal window, and running the chef verify command.
Welcome back! In this lesson I’ll cover how to get an environment setup that will enable you to get started with Chef.
Here’s my disclaimer: If you’re a Ruby developer you probably already have a development environment setup. Maybe you’re using RVM or rbenv, maybe you’re doing all of your development inside of a Docker container, or you’re using some other setup.
There’s no shortage of options here. So if you have your preferred setup then feel free to use it. However in an attempt to reduce the complexity for people getting started with Chef, I’m not going to worry about managing Ruby versions.
Okay, with the disclaimer out of the way, here’s the plan: I’m going to show you how to use Kitchen with VirtualBox and Vagrant to configure a virtual machine to test from.
The reason I’m going to use VirtualBox instead of VMWare is simply because VirtualBox is free. And I’m using Vagrant so that I can test locally. Although Kitchen does allow you to use other providers including docker and even cloud providers.
I’ll download the latest versions of VirtualBox and Vagrant and get them installed. Once installed I’ll be to install the Chef Developer Kit on my Mac.
In case one or both of these tools are new to you here’s a quick description. VirtualBox is a virtualization tool that allows you to host virtual machines. And Vagrant is a virtual machine management tool that allows you download and provision different types of guest operating systems. And Vagrant isn’t limited to using VirtualBox, it also has adapters for VMWare, Docker, and others.
I’m using a Mac, so I’m going to show this from the perspective of Mac user. If you’re using another OS, I’m going to leave that to you to get these installed. There’s plenty of documentation out there for different platforms, should you need it.
So, let’s start with the download page for VirtualBox. And I’ll download the latest version for the Mac.
And once that downloads, I can run through the installer. It’s a pretty standard Mac installer package. So I’ll click through the defaults until it’s complete.
And with that done I’ll have VirtualBox added to my Applications directory.
Next up, I need to install Vagrant, so I’ll go to the vagrantup.com website and head over to the downloads page. And I’ll download the Mac version.
It’s roughly 80 MBs, so I’ll let that download, and once it’s done I can run through the installer. Just like the other one, it’s a standard Mac installer package, so I’ll just click through the steps.
Perfect! With that all installed I’m ready to install the Chef development kit. You can see here on the downloads page there are installer packages for Debian, Red Hat Enterprise, macOS, Ubuntu, and Windows. I’m going to install the Mac version. Again, if you’re using a different OS, I’m going to leave the installation to you.
So, it’s again, a matter of clicking next through the installer prompts until it’s complete. And once it’s complete to make sure everything is working open up a terminal window, and run the command “chef verify.” It’s not uncommon for this to take a minute. However, once it’s complete, if it returns a list of success messages, then you’re ready to start developing.
Alright, with all of this finally installed, it’s time to get started developing recipes. So if you’re ready to create your first Chef recipe then let’s get started in the next lesson!
About the Author
Ben Lambert is a software engineer and was previously the lead author for DevOps and Microsoft Azure training content at Cloud Academy. His courses and learning paths covered Cloud Ecosystem technologies such as DC/OS, configuration management tools, and containers. As a software engineer, Ben’s experience includes building highly available web and mobile apps. When he’s not building software, he’s hiking, camping, or creating video games.