HomeHOWTOSInstall and Use Vagrant on Rocky Linux 9|AlmaLinux 9

Install and Use Vagrant on Rocky Linux 9|AlmaLinux 9

Vagrant is an open-source tool for creating and managing virtual machine environments in a unified workflow. It provides the simplest and most straightforward command-line interface for managing virtual environments. This decreases the time required to set up the development environment while enhancing production parity.

In this guide, we will show you how to Install and Use Vagrant on Rocky Linux 9|AlmaLinux 9.

Amazing features of Vagrant

Vagrant has the following cool features:

  • It is built on industry-standard technology and is managed through a single, consistent workflow.
  • It simplifies the process of configuring an environment.
  • It standardizes platforms’ ecosystems.
  • Virtual machines can be created quickly and easily on top of VirtualBox, VMware, AWS, or any other provider.
  • It is a cross-platform application.

This guide will walk you through installing and using Vagrant on Rocky Linux 9|AlmaLinux 9. Let’s dive in and appreciate this tool’s magnificence!

Step 1~ Install Vagrant on Rocky Linux 9|AlmaLinux 9

You must first install a hypervisor on your Rocky Linux 9|AlmaLinux 9 system before we can start.
We’ll be using Virtualbox in this situation, which can be set up using the instructions below;

Install VirtualBox 7.0 on Rocky Linux 9|AlmaLinux 9

After installing a preferred hypervisor, proceed to install Vagrant on Rocky Linux 9|AlmaLinux 9.

To do so, first, add the Vagrant repository to the system.

$ sudo yum install yum-utils -y
$ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo

Step 2~ Install Vagrant

Vagrant can be installed on Rocky Linux 9|AlmaLinux 9 using the command:

$ sudo yum install vagrant

Dependency tree:

Last metadata expiration check: 0:00:12 ago on Fri 24 Feb 2023 10:34:36 PM EAT.
Dependencies resolved.
==============================================================================================================================
 Package                      Architecture                Version                        Repository                      Size
==============================================================================================================================
Installing:
 vagrant                      x86_64                      2.3.4-1                        hashicorp                      103 M

Transaction Summary
==============================================================================================================================
Install  1 Package

Total download size: 103 M
Installed size: 249 M
Is this ok [y/N]: y

Check the version;

$ vagrant --version
Vagrant 2.3.4

Step 3~ Using Vagrant in conjunction with VirtualBox

Starting a Vagrant project is as simple as defining a Vagrantfile and creating the project root directory.

$ sudo  mkdir ~/my-vagrant-project
$ cd ~/my-vagrant-project

Now, download a Vagrant box file for the desired VM and configure it.
For instance, Ubuntu 20.04.

Vagrant box catalog page.

$ vagrant box add generic/ubuntu2004 --provider=virtualbox

Sample output:

==> box: Loading metadata for box 'generic/ubuntu2004'
    box: URL: https://vagrantcloud.com/generic/ubuntu2004
==> box: Adding box 'generic/ubuntu2004' (v4.2.14) for provider: virtualbox
    box: Downloading: https://vagrantcloud.com/generic/boxes/ubuntu2004/versions/4.2.14/providers/virtualbox.box
    box: Calculating and comparing box checksum...
==> box: Successfully added box 'generic/ubuntu2004' (v4.2.14) for 'virtualbox'!

Using the init command, create a Vagrant file for the VM:

$ sudo vagrant init generic/ubuntu2004
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 view the Vagrantfile here:

$ cat Vagrantfile

Output:

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "generic/ubuntu2004"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false
.........
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

Start the VM with the following command:

$ vagrant up

The project directory is mounted by Vagrant as /vagrant in the virtual computer. This enables you to edit project files on your host computer.

Run the following command to connect through ssh to the virtual machine:

$ vagrant ssh

Use the following command to terminate the virtual machine:

$  vagrant halt

Enter the command below to destroy all resources created during the machine’s creation:

$ vagrant destroy

Wrapping up

That concludes this fantastic guide on how to use Vagrant with VirtualBox on Rocky Linux 9|AlmaLinux 9. I hope you found this useful.

For more info, visit Vagrant documentation.

Other manuals:

Install Prometheus on Rocky Linux 9|AlmaLinux 9

How To install Python 3.11 on Rocky Linux 9|AlmaLinux 9

How To Install Google Chrome on Rocky Linux 9|AlmaLinux 9

Install KDE Desktop Environment on Ubuntu 22.04|20.04

How To Install TeamViewer on Ubuntu 22.04|20.0

- Advertisment -

Recent posts

LEAVE A REPLY

Please enter your comment!
Please enter your name here