How to Install Vagrant on Ubuntu 20.04
 

How to Install Vagrant on Ubuntu 20.04

 

The ease of creating and destroying the virtual machine instances on the fly makes it more prominent in many production environments. Because of the popularity of VMs, in this article, I am going to explain how to install Vagrant on Ubuntu 20.04.

What is Vagrant?

If you are a first time user, then you might want to know what Vagrant is, in the first place?

Vagrant is a command-line tool built to create and manage virtual machines. Out of the box, Vagrant supports VirtualBox, Hyper-V, and Docker. But, Vagrant has the ability to manage other types of machines as well, such as KVM (libvirt), VMware and AWS through Vagrant plugin system.

It has pre-configured boxes (the OS images, in simple word) a vagrantfile to configure a VM. More on this is out of the scope of this page but I will cover those in a vagrant specific page.

How to Install Vagrant on Ubuntu 20.04?

I will show you by installing a CentOS 8 on top of Virtualbox. So, make sure that you have already installed VirtualBox on Ubuntu 20.04.

Vagrant can be installed from the Ubuntu’s repository but that is not recommended as has a very old version.
So, we will be downloading the latest Vagrant from the official download page.

Download Vagrant:

As of writing this guide Vagrant 2.2.9 was the latest. But you make sure to visit the above download page to get the latest one!

Download the latest Vagrant using wget or curl command:

wget https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb

(or)

curl -O https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb

Install Vagrant:

Once the file is downloaded, execute the below command to install it:

sudo apt install ./vagrant_2.2.9_x86_64.deb

Verify Vagrant Installation

To verify if it is installed successfully, execute the below command:

vagrant --version

Output:

Vagrant 2.2.9

Install Linux Distro using Vagrant on Ubuntu 20.04

It is recommended that you create a project directory and then work on that directory for any Vagrant installations etc.

Execute the below commands to create and cd to the project directory:

mkdir ~/vagrant-projects
cd ~/vagrant-projects

Initialize Vagrantfile

Now, initialize a vagrantfile with a specific box that you want to use.

Usually, Boxes are related to distro. VM and are provider specific. You can browse through all available Vagrant boxes.

In this demo I will use the CentOS 7 box to install:

vagrant init centos/7

Output:

A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

You can open the Vagrantfile, and re-configure it as per your project needs.

Now, execute the below command to create and configure the virtual machine:

vagrant up

Output:

==> default: Configuring and enabling network interfaces...
    default: SSH address: 192.168.10.56:22
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Rsyncing folder: /home/cpqlinux/Vagrant/vagrant-projects/ => /vagrant

Vagrant mounts the project directory on the host machine at /vagrant in the newly created virtual machine. So, you do not need to create a shared directory for virtual machines to work on your VM project’s files on your host machine.
==> default: Rsyncing folder: /home/cpqlinux/Vagrant/vagrant-projects/ => /vagrant

Other Useful Vagrant commands

Execute the below to login to the VM via SSH:

vagrant ssh

To shutdown the virtual machine execute the below command:

vagrant halt

To destroy all resources created during the creation of the machine, execute below command:

vagrant destroy

That’s on installing Vagrant on Ubuntu 20.04 that helps in creating, managing and destroying virtual machines. For more information, you can always visit the official Vagrant docs page.

Previous How to Install ADB Fastboot on Linux
Next Stranger Things, JavaScript Edition
 

About author

shibaa987
shibaa987 274 posts

Linux kernel developer and a firmware developer with an experience of 10+ years.

View all posts by this author →

You might also like

Installation 0 Comments

PXE Server Setup – whitepaper

This post was last updated on May 26th, 2020 at 09:37 pmLinux PXE Server This whitepaper will describe how to set up a pxe server. Hardware Required: HP ProLiant Server,

Installation 0 Comments

Compaq Smart-2/E Array Controller

This post was last updated on May 27th, 2020 at 05:15 pm Contents1 Spare# 194752-001 Assembly# 194771-001 Option# 194751-0012 Hardware Setup:3 Software Install:4 Module Options5 Building a new Initrd6 Updating

Installation 0 Comments

Automated Installation of Red Hat Linux 7, 8 and AS 2.1 via PXE

This post was last updated on May 26th, 2020 at 09:33 pmThis document discusses the automated installation of Red Hat Linux 7.2, 7.3, 8.0, and AS 2.1 via PXE. Overview

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply