0% found this document useful (0 votes)
119 views11 pages

Vagrant: Virtualbox Provider Guide

This document provides instructions for configuring and using a VirtualBox virtual machine (VM) with Vagrant. It describes how to install prerequisites, add a VM image, start and connect to the VM, provision it with configuration scripts, customize CPU/RAM settings, configure networking, copy files to the VM, enable the GUI, and references for further configuration.

Uploaded by

Manoj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
119 views11 pages

Vagrant: Virtualbox Provider Guide

This document provides instructions for configuring and using a VirtualBox virtual machine (VM) with Vagrant. It describes how to install prerequisites, add a VM image, start and connect to the VM, provision it with configuration scripts, customize CPU/RAM settings, configure networking, copy files to the VM, enable the GUI, and references for further configuration.

Uploaded by

Manoj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Vagrant

Virtualbox provider guide


Install
Prerequisites

apt-get -y install virtualbox virtualbox-dkms vagrant

VM image

vagrant box add trusty64 https://oss-


binaries.phusionpassenger.com/vagrant/boxes/latest/ubuntu-14.04-amd64-
vbox.box
Operate
Start image

vagrant init && vagrant up

Connect

vagrant ssh

Suspend or shutdown

vagrant suspend && vagrant halt


Provisioning
Create bootstrap.sh with all the configuration

Modify Vagrantfile

config.vm.provision :shell, path: "bootstrap.sh"

Provision

vagrant provision
Bootstrap as a regular user
By default script is run as root, to run as a different user do the following.
case $(id -u) in

0) # doing root tasks

sudo -u vagrant -i $0

;;

*) # doing user tasks

;;

esac
Configure CPU and RAM
Modify Vagrantfile

config.vm.provider "virtualbox" do |vb|


vb.customize ["modifyvm", :id, "--memory", "1024"]

vb.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]

vb.customize ["modifyvm", :id, "--ioapic", "on"]

vb.customize ["modifyvm", :id, "--cpus", "4"]


end
Configure network
Modify Vagrantfile

config.vm.network "public_network", bridge: "br-1", ip: "192.168.56.2"

config.vm.network "public_network", bridge: "br-2", ip: "192.168.57.2"

config.vm.network "public_network", bridge: "br-3", ip: "192.168.58.2"


Copy files to VM
Vagrant.configure("2") do |config|
# ... other configuration

config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"


end
GUI
config.vm.provider "virtualbox" do |vb|
vb.gui = true
end
References
Vagrant virtualbox configuration

How to make Vagrant performance not suck


My blog
Learning Network Programming

You might also like