Home Vagrant Getting Started with Vagrant and VirtualBox – Part 1

Getting Started with Vagrant and VirtualBox – Part 1

LinuxShellTips is happy to present a series on Vagrant. If you are someone who is using virtualization software like VirtualBox, Hyper-V, KVM, Docker, and AWS then this tool will be a great addition to your toolbox.

This Vagrant series is focused on introducing what is vagrant, core aspects of vagrant, and automation features it provides.

Table of Contents

  1. Getting started with Vagrant
  2. How to Install Vagrant in Linux
  3. How to Create Virtual Machine with Vagrant and VirtualBox
  4. How to Control Vagrant Box Using Vagrant commands
  5. How to Work with File and Shell Provisioner in Vagrant
  6. How to Work with Ansible Provisioner in Vagrant
  7. How to Create a Vagrant Box from an Existing Box

Let’s get started…

What is Vagrant?

Vagrant is created by Hashi Corp and released as an open-source solution for building and deploying virtual environments in a single workflow. To put it in simple words, vagrant automates setting up your virtual environments.

Vagrant is a command-line tool and written in Ruby. If you think you need to learn ruby to work with vagrants, no you are wrong. Vagrant exposes the configuration file in a ruby format which is easy to read and modify even for a new user.

Before using Vagrant it is important to understand its core capabilities. There are two important terms to understand.

  • Provider
  • Provisioner

What is Vagrant Provider?

The provider is a term that refers to the hypervisor that you will be used to work with virtual machines. Virtualbox, Docker, Hyper-V, KVM are some of the hypervisors and vagrant also supports AWS with the help of plugins.

What is Vagrant Provisioner?

Provisioner allows you to automate the workflow. It uses tools like shell, chef-solo, Ansible to automate your workflow when creating the Virtual machine. It is also possible to create your own provisioner and integrate with the vagrant.

In this series, we will be seeing how the shell and ansible provisioner works and we will also be setting up an ansible lab environment using vagrant.

Vagrant Architecture
Vagrant Architecture

The above diagram explains the architecture of the Vagrant that always interacts with the Provider (VirtualBox, Hyper-V..) and sets up the virtual machine in a headless state.

You will have a vagrant configuration file where all your virtual machine and provider-related configuration will be placed. This vagrant file will be in ruby format. If you are good at ruby you can include ruby codes to tweak some features and shortened the configuration when your try to pass the same parameter to multiple virtual machines in the configuration file.

Whatever we discussed till now will be explained in detail in the subsequent section with hands-on examples and a final project in setting up an ansible lab in an automated way.

In the next article, we will see how to install and remove vagrant in different Linux distributions.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.