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?
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 the latest Vagrant using wget or curl command:
curl -O https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb
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:
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
Now, initialize a vagrantfile with a specific box that you want to use.
In this demo I will use the CentOS 7 box to install:
vagrant init centos/7
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:
==> 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:
To shutdown the virtual machine execute the below command:
To destroy all resources created during the creation of the machine, execute below command:
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.
You might also like
This post was last updated on June 23rd, 2020 at 08:05 pmAndroid studio is the official IDE for android application development by Google. It is based on JetBrains’ IntelliJ IDEA
This post was last updated on June 1st, 2020 at 12:07 pm The PL4500 is about the only server I can think of that Linux cannot use the embedded SCSI