19.6 C
New York

Installing and Configuring Vagrant on Ubuntu 20.04

Published:

Introduction to Vagrant

Vagrant stands as a powerful command-line tool utilized for the seamless construction and management of virtual machines. It facilitates the provisioning of machines atop various providers, including VirtualBox, Hyper-V, and Docker, with extensibility through plugins enabling support for additional providers like Libvirt (KVM), VMware, and AWS. Developers predominantly leverage Vagrant to establish versatile development environments that transcend operating system boundaries.

Installation of Vagrant on Ubuntu:

While VirtualBox is the default provider for Vagrant, it necessitates prior installation. Execute the following commands to install VirtualBox:

sudo apt update
sudo apt install virtualbox

Although Vagrant is available within Ubuntu’s repositories, the packaged version may not be the latest. Therefore, we’ll procure and install the most recent Vagrant release from the official site. Presently, version 2.2.9 is the latest stable iteration. You can check for updates on the Vagrant downloads page.

  1. Download the Vagrant package using wget:
curl -O https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.deb
  1. Install the downloaded package:
sudo apt install ./vagrant_2.2.9_x86_64.deb

To confirm a successful installation, ascertain the Vagrant version:

vagrant --version

Getting Started with Vagrant

The initiation of a Vagrant project is a straightforward process, involving the establishment of a project root directory and definition of a Vagrantfile.

  1. Create and navigate into the project directory:
mkdir ~/my-vagrant-project
cd ~/my-vagrant-project
  1. Initialize a new Vagrantfile:
vagrant init centos/8

The Vagrantfile serves as a Ruby-based configuration script delineating virtual machine setup. Customize it as per your requirements.

  1. Bring the virtual machine to life by executing:
vagrant up

Interacting with Vagrant

  • SSH into the virtual machine:
vagrant ssh
  • Halt the virtual machine:
vagrant halt
  • Obliterate all machine resources:
vagrant destroy

Conclusion

You’ve now successfully installed Vagrant on Ubuntu 20.04 and established a rudimentary Vagrant project. Delve deeper into Vagrant’s capabilities by consulting the official documentation.

For further insights into Vagrant’s functionalities, refer to the official Vagrant documentation. Queries and comments are welcomed below.

Related articles

Recent articles