How to Install Vagrant on Debian 10 Linux

[ad_1]

Vagrant
is an open-source command-line tool for building and managing virtual machine environments. By default, Vagrant can provision machines on top of VirtualBox, Hyper-V. and Docker. Other providers such as Libvirt (KVM), VMware and AWS can be installed via the Vagrant plugin system.

Typically, Vagrant is used by developers for setting up a development environment that matches the production.

This tutorial covers the installation of Vagrant on a Debian 10, Buster. We’ll be using the VirtualBox provider, which is the default provider for Vagrant.

Prerequisites #

Ensure that you have met the following prerequisites before you start the installation:

Installing Vagrant on Debian #

The Vagrant package available in the standard Debian’s repositories is a little outdated. The latest version of Vagrant can be downloaded as a deb file from the official Vagrant site.

At the time of writing this article, the latest stable version of Vagrant is version 2.2.6. Before continuing with the next steps, visit the Vagrant Download page
to check if a newer version is available.

Download the Vagrant package with the following curl command
:

curl -O https://releases.hashicorp.com/vagrant/2.2.6/vagrant_2.2.6_x86_64.deb

Once the .deb file is downloaded, install it by typing:

sudo apt updatesudo apt install ./vagrant_2.2.6_x86_64.deb

To verify that the installation was successful run the following command which prints the Vagrant version:

vagrant --version

The output should look something like this:

Vagrant 2.2.6

That’s it! You have successfully installed Vagrant on your Debian system, and you can start using it.

Getting Started with Vagrant #

In this section, we’ll show you how to create a development environment.

The first step is to create a directory
which will be the project root directory and hold the Vagrantfile file:

mkdir ~/my-first-vagrant-project

Vagrantfile is a Ruby file that describes how the virtual machine will be configured when created.

The next step is to initialize a new Vagrantfile using the vagrant init command and specify the box you wish to use.

Boxes are the package format for the Vagrant environments and are provider-specific. You can find a list of publicly available Vagrant Boxes on the Vagrant box catalog
page.

Navigate
to the project directory and initialize a new Vagrantfile:

cd ~/my-first-vagrant-projectvagrant 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
with your text editor, read the comments, and make adjustments according to your needs.

Run the vagrant up command to create and configure the virtual machine as defined in the Vagrantfile:

vagrant up
==> default: Configuring and enabling network interfaces...
    default: SSH address: 192.168.121.27:22
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Rsyncing folder: /home/linuxize/Vagrant/my-first-vagrant-project/ => /vagrant

Vagrant mounts the project directory at /vagrant in the virtual machine. This allows you to work on the project’s files on your host machine.

To ssh into the virtual machine, run:

vagrant ssh

You can stop the virtual machine with the following command:

vagrant halt

The command below stops the running machine and destroys all resources that were created during the creation of the machine:

vagrant destroy

Conclusion #

We have shown you how to install Vagrant on Debian 10 and how to create a basic development environment.

For more information about Vagrant, visit the Vagrant documentation
page.

If you have any questions, please leave a comment below.

[ad_2]

Source link

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.