Introduction
This document provides a detailed guide on installing Vagrant on Debian 12 Bookworm. We will use the 5W1H method (What, Who, Where, When, Why, How) to structure the content, followed by the Consequences and Conclusion sections.
Overview
What
Vagrant is an open-source tool for building and managing virtualized development environments. It simplifies the workflow of virtual machine provisioning, configuration, and deployment.
Who
This guide is for developers and system administrators who need to set up consistent development environments.
Where
This guide is applicable to the Debian 12 Bookworm operating system.
When
This guide is relevant as of the release of Debian 12 Bookworm.
Why
Installing Vagrant offers several advantages, including the ease of creating reproducible development environments, reducing the "works on my machine" problem, and streamlining the setup of multi-machine environments.
Pros | Cons |
---|---|
Automates VM provisioning and configuration | Can consume considerable resources |
Ensures consistent environments | May have a learning curve for beginners |
Supports multiple providers like VirtualBox, VMware, AWS | Dependency on additional tools and plugins |
How
The following steps illustrate how to install Vagrant on Debian 12 Bookworm:
- Update package list: sudo apt update
- Install dependencies: sudo apt install -y gnupg software-properties-common
- Add HashiCorp's official GPG key: wget -O- https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
- Add the official HashiCorp Linux repository: sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
- Install Vagrant: sudo apt update & sudo apt install vagrant
- Verify the installation: vagrant --version
Consequences
Installing Vagrant has several consequences:
Positive |
|
Negative |
|
Conclusion
Vagrant is a powerful tool that simplifies the process of setting up development environments. By following this guide, developers and system administrators can quickly and efficiently install Vagrant on Debian 12 Bookworm, ensuring consistent and reproducible environments. While there are some cons, the benefits typically outweigh them, making Vagrant a worthwhile addition to any development workflow.
Install
Install Vagrant that is wrapper tool for Virtualization software like Libvirt or VirtualBox and others. Vagrant supports many Virtualization software like VirtualBox or Libvirt and others, this example is based on the Libvirt installed environment.
Step [1]Install Vagrant.
root@bizantum:~# apt -y install vagrant-libvirt
# if use by common users, add them to [libvirt] group
root@bizantum:~# usermod -aG libvirt debian
Step [2]Basic usage of Vagrant. It's possible to use it by any common user.
# download and add virtual machine images
# for downloadable image, refer to the official site below
# ⇒ https://app.vagrantup.com/boxes/search
debian@bizantum:~$ vagrant box add generic/debian11 --provider libvirt
==> box: Loading metadata for box 'generic/debian11'
box: URL: https://vagrantcloud.com/generic/debian11
==> box: Adding box 'generic/debian11' (v4.2.16) for provider: libvirt
box: Downloading: https://vagrantcloud.com/generic/boxes/debian11/versions/4.2.16/providers/libvirt.box
box: Calculating and comparing box checksum...
==> box: Successfully added box 'generic/debian11' (v4.2.16) for 'libvirt'!
# initialize ([Vagrantfile] is created on the current path)
debian@bizantum:~$ vagrant init generic/debian11
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.
# start virtual machine
debian@bizantum:~$ vagrant up
Bringing machine 'default' up with 'libvirt' provider...
==> default: Checking if box 'generic/debian11' version '4.2.16' is up to date...
==> default: Uploading base box image as volume into Libvirt storage...
==> default: Creating image (snapshot of base box volume).
==> default: Creating domain with the following settings...
==> default: -- Name: debian_default
==> default: -- Description: Source: /home/debian/Vagrantfile
==> default: -- Domain type: kvm
==> default: -- Cpus: 2
==> default: -- Feature: acpi
==> default: -- Feature: apic
==> default: -- Feature: pae
==> default: -- Clock offset: utc
==> default: -- Memory: 2048M
==> default: -- Base box: generic/debian11
==> default: -- Storage pool: default
==> default: -- Image(vda): /var/lib/libvirt/images/debian_default.img, virtio, 128G
==> default: -- Disk driver opts: cache='default'
==> default: -- Graphics Type: vnc
==> default: -- Video Type: cirrus
==> default: -- Video VRAM: 256
==> default: -- Video 3D accel: false
==> default: -- Keymap: en-us
==> default: -- TPM Backend: passthrough
==> default: -- INPUT: type=mouse, bus=ps2
==> default: Creating shared folders metadata...
==> default: Starting domain.
==> default: Domain launching with graphics connection settings...
==> default: -- Graphics Port: 5900
==> default: -- Graphics IP: 127.0.0.1
==> default: -- Graphics Password: Not defined
==> default: -- Graphics Websocket: 5700
==> default: Waiting for domain to get an IP address...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 192.168.121.211:22
default: SSH username: vagrant
default: SSH auth method: private key
default:
default: Vagrant insecure key detected. Vagrant will automatically replace
default: this with a newly generated keypair for better security.
default:
default: Inserting generated public key within guest...
default: Removing insecure key from the guest if it's present...
default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
# show state of virtual machine
debian@bizantum:~$ vagrant status
Current machine states:
default running (libvirt)
The Libvirt domain is running. To stop this machine, you can run
`vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
# connect to virtual machine with SSH
debian@bizantum:~$ vagrant ssh
vagrant@debian11:~$ uname -a
Linux debian11.localdomain 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux
vagrant@debian11:~$ exit
# stop virtual machine
debian@bizantum:~$ vagrant halt
==> default: Attempting graceful shutdown of VM...
# if you'd like to change settings of virtual machine, edit Vagrantfile
debian@bizantum:~$ vi Vagrantfile
# for example to change CPU and Memory settings
# uncomment line 57 like follows and add or change values
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 = "4096"
vb.cpus = 2
end
- Get link
- X
- Other Apps
Comments
Post a Comment
Thank you for your comment! We appreciate your feedback, feel free to check out more of our articles.
Best regards, Bizantum Blog Team.