# Vagrant and VirtualBox

The project in this course (and some other work) can be deployed on virtual machines (most easily provided by VirtualBox) that are provisioned (by Vagrant) and configured (by Chef or similar) automatically.

## Getting Set Up: your computer

You should be able to use any OS on your computer to set up the VMs: both of the tools we need are supported on Linux, OSX, and Windows.

Your computer needs to be powerful enough to do whatever you are using it for (web browser, IDE, etc.), plus provide resources to a small virtual machine: maybe one core and 1 GB of memory. If that doesn't describe your computer, then see the CSIL instructions below.

1. Install VirtualBox. You can do this in Windows, OSX, or Linux. In Ubuntu, this can by done by installing the package virtualbox (or virtualbox-qt if you want the GUI tools too).
2. Install Vagrant. You can also do this in Windows, OSX, or Linux. In Ubuntu, install the vagrant package.
3. Get the code for the project. This will likely be from GitLab and should include a file named Vagrantfile in the project root. See ProjectRepo for details on getting your repository set up.
1. That means you'll need Git installed: use the command line tools for Linux or OSX. Git for Windows comes with the Git BASH shell, which is nice to work with and can do everything you need.

If you try to start a virtual machine and it seems to hang, you can try starting a VM from the VirtualBox GUI: you can see error messages there. The most likely cause is not having processor virtualization extensions, either because they're off in your BIOS, or because you're trying to run a VM inside another VM.

If you are having problems getting any VM to start, you have have your processor's virtualization extensions turned off in the BIOS. (This seems to be common in laptops, by default.) It should be easy enough to enable the extension.

## Getting Set Up: CSIL Linux

Everything you need should be available on the Linux side of any of the CSIL workstations. You can use the vagrant command as expected.

You may have to comment-in these lines near the end of the Vagrantfile:

chef.channel = "stable"
chef.version = "12.10.24"

## Getting Set Up: CSIL Linux Remotely

As above, the tools you need should be available on CSIL Linux machines. That includes csil-cpu4.csil.sfu.ca, which you can connect to remotely with this command (or your SSH client's adaptation of it):

ssh -p24 -L 8080:localhost:8080 csil-cpu4.csil.sfu.ca

This will forward port 8080 from there to your localhost: adapt as necessary to get the port you're using for your HTTP server.

## Working with VMs

The vagrant command is used to work with your virtual machine(s).

vagrant up
Start a VM, using configuration from the Vagrantfile in the current directory. The first time you start a particular VM, this might take a while: it will download the box image and provision the VM.
vagrant provision
Re-run the provisioner (Chef, Puppet, etc) on the VM. This will need to be done if you (or your group members) update the recipes.
vagrant ssh
SSH in to the VM so you get a command line there.
vagrant halt
Shut down the VM
vagrant destroy
Destroy the VM image. You can (should be able to?) recreate it by doing a vagrant up and letting it provision itself.
Updated Mon Aug. 30 2021, 07:36 by ggbaker.