Skip to content

Vagrant

Vagrant system environment

VAGRANT_HOME I:\vagrant\vagrant.d

Vagrant upgrade version

Download from https://developer.hashicorp.com/vagrant/install

Vagrant update plugins

vagrant plugin update

Create Vagrantfile with VM configuration

# -*- mode: ruby -*-

ISO = "bento/ubuntu-24.04"
NET = "192.168.1."
DOMAIN = ".local"
HOST_PREFIX = "django-book"

servers = [
  {
    :hostname => HOST_PREFIX + DOMAIN,
    :ip => NET + "128",
    :ram => 8192,
    :core => 2
  }
]

Vagrant.configure(2) do |config|
  config.vm.synced_folder ".", "/vagrant", disabled: false
  servers.each do |machine|
    config.vm.define machine[:hostname] do |node|
      node.vm.box = ISO
      node.vm.hostname = machine[:hostname]
      node.vm.network "public_network", bridge: 'Intel(R) Ethernet Connection (2) I219-V', ip: machine[:ip]
      node.vm.provider "virtualbox" do |vb|
        vb.customize ["modifyvm", :id, "--memory", machine[:ram]]
        vb.customize ["modifyvm", :id, "--cpus", machine[:core]]
        vb.name = machine[:hostname]
      end
    end
  end
end

Start virtual machine

cd <directory with Vagrantfile>
vagrant up

Connect to running Vagrant mahcine

vagrant ssh

Open directory mapped from local machine

cd /vagrant/