Featured image of post How to Install Vagrant on Debian 11

How to Install Vagrant on Debian 11

Install vagrant work with libervit

Update apt sourcelist

1
sudo apt update

Install pre-request software packages

1
sudo apt install apt-transport-https ca-certificates curl software-properties-common

Add vagrant repository

1
2
3
4
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install vagrant
vagrant version

Add vagrant provider

Option 1: Install libvirt as vagrant provider

1
2
3
4
5
6
apt install  -y libvirt-dev
systemctl stop nfs-kernel-server.service
systemctl disable nfs-kernel-server.service
systemctl enable nfs-kernel-server.service
systemctl start nfs-kernel-server.service
vagrant plugin install vagrant-libvirt

Create a virtual machine

1
2
3
4
mkdir playbooks
cd playbooks
vagrant init debian/bullseye64
vagrant up --provider=libvirt

Option 2: Install virtualbox as provider

1
2
3
4
5
6
7
sudo apt install curl wget gnupg2 lsb-release -y
curl -fsSL https://www.virtualbox.org/download/oracle_vbox_2016.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/vbox.gpg
curl -fsSL https://www.virtualbox.org/download/oracle_vbox.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/oracle_vbox.gpg
echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
sudo apt update
sudo apt install linux-headers-$(uname -r) dkms 
sudo apt install virtualbox-7.0 -y

Create a virtual machine

1
2
3
4
mkdir playbooks
cd playbooks
vagrant init ubuntu/focal64
vagrant up --provider=virtualbox

Vagrant Stop

1
vagrant stop

Vagrant Destory

1
vagrant destroy

Uninstall vagrant

1
2
sudo rm -rf /opt/vagrant
sudo apt-get remove --auto-remove vagrant

Reference

Built with Hugo
Theme Stack designed by Jimmy