Getting Started with Vagrant
Learn how to set up your first Vagrant environment, manage virtual machines, and configure complex multi-node labs for development using VirtualBox, QEMU, or libvirt.
To begin, you’ll need to configure your Vagrantfile. You can refer to the official vagrant documentation
First, install Vagrant and VirtualBox using the following commands:
sudo apt install vagrantsudo apt install virtualboxVagrant is a powerful tool that allows you to manage and run virtual machines (VMs) using your preferred virtualization software. While VirtualBox is the most common provider, Vagrant also works seamlessly with other tools like QEMU, virt-manager (via the libvirt provider), or even Docker and VMware. This provides a consistent and efficient way to work with VMs, regardless of the underlying virtualization technology.
You need to create a VagrantFile. Here is a simple example:
Vagrant.configure("2") do |config| config.vm.box = "ubuntu/trusty64" config.vm.box_version = "20191107.0.0"endYou can also define multiple machines in a single file to create complex environments:
Vagrant.configure("2") do |config| (1..2).each do |i| config.vm.define "master#{i}" do |master| master.vm.box = "almalinux/9" master.vm.network "private_network", ip: "192.168.10.1#{i}" # master.ssh.host = "192.168.10.1#{i}" master.vm.provision "file", source: "~/.ssh/id_rsa.pub", destination: "~/.ssh/authorized_keys" master.vm.provider "virtualbox" do |v| v.memory = 4096 v.cpus = 2 end end endend