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
- Getting started with Vagrant
- How to Install Vagrant in Linux
- How to Create Virtual Machine with Vagrant and VirtualBox
- How to Control Vagrant Box Using Vagrant commands
- How to Work with File and Shell Provisioner in Vagrant
- How to Work with Ansible Provisioner in Vagrant
- Setting up multiple machines in one Vagrant File
- Setting up 5 Node ansible Lab using Vagrant
- Building a custom vagrant 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.
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.
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.