DevOps 101: Installing Vagrant on Mac OS High Sierra using Brew

Tomorrow we will be doing Development and Operations (DevOps) course for the boot-camp. Our first task is to set up the environment for the 2 most famous virtualization configuration technology in the IT world (PS: Vagrant and Docker claims that they are more than configuration technology, this definition is just for simplification). This step by step guide will help anyone installing vagrant and set up their first ubuntu 16.04 (xenial).

Install Homebrew

The first step is to install homebrew. Basically, homebrew is for installing thins that Apple didn’t install for you. Cool ain’t it?

Command to install brew

Once installed, you can type the command

brew doctor
brew prune #In case you have some unused brew - Optional
brew update

Install VirtualBox Cask

For using vagrant and docker, you need to put them on top of virtualization, to do this you need to install one of the virtualization stacks. The easiest one, for me is virtual box, because I use that most of the time in my college life. I will review later what is the strength and weakness between all the virtualization stacks. How to install virtualbox using brew, just type.

brew cask install virtualbox

Install Vagrant cask

To install vagrant using cask is very easy, just follow the simple instruction and vagrant will be installed. But there is some setting we need to do before Mac Os can install

Open the Apple Logo on top left → System Preferences → Security & Privacy

The setting that should open

Click the lock to make changes, and change the Allow apps downloaded from to App store and identified developers. Click the lock again and do the command.

brew cask install vagrant

Wait several minutes and congrats! You successfully installed vagrant on your system.

Set up Ubuntu 16.04 for Vagrant

I often make separate folder for my projects, so for vagrant I create a new folder called VagrantProjects

mkdir ~/VagrantProjects

From there I create folder where I store my projecs. For example in this case I create Ubuntu/Xenial16.04

mkdir ~/VagrantProjects/Ubuntu/Xenial16.04

I come inside the directory and put the command

vagrant init

It creates a Vagrantfile inside the directory. Vagrantfile is a configuration script that will run and create our environment. So, now we need to code the Vagrantfile to create ubuntu/xenial16.04 image. In my case, I just change the config vm.box to ubuntu/xenial64. And added the provision of changing password to ubuntu:ubuntu.

After that, I just run vagrant up.

WARNING!!!
If it is your first time writing vagrant up, expect it to run a little bit longer, because vagrant need to configure the box to virtual box.
Also make sure you have good internet connection. Don't use phone tethering.

If it is already finished without error then cool! You are ready to go. Just type vagrant ssh from the folder directory to come inside the terminals

Vagrant SSH

you can do anything with your ubuntu vagrant now.

For more information about vagrant, visit the official docs here

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade