Vagrant is a useful tool to quickly create pre-defined Virtual Machines (VMs) for easier code development. E.g. a user can run Windows/OS X/Ubuntu but compile & run the software on CentOS 6/7.
This repository gives vagrant examples and explains customization options.
- cernvm: examples based on the CernVM image (Scientific Linux 6)
- Install Virtualbox
- Make sure Virtualisation is enabled in the BIOS (
Intel Virtualization Technology (Intel VT)
orAMD-V
)
- Make sure Virtualisation is enabled in the BIOS (
- Install Vagrant
- (Recommended on Windows) Install Git for Windows
Let's say you have an existing project folder that contains the code with the name
myproject
. The first step is to pick one of the example Vagrant files and save it
under myproject/Vagrantfile
.
By default most examples will map the myproject
folder on the host machine
to /vagrant
on the VM. This means you can use any editor available on the host
machine and compile & run the code in the VM.
Full documentation for vagrant commands can be found on the official Vagrant site.
To start the VM:
cd <path to myproject>
vagrant up
vagrant ssh
To stop the VM
vagrant halt
Navigate to the project folder, right-click on it and select Git Bash Here
.
This will open a unix-like shell that you can use for Vagrant and git commands.
vagrant up
You can now either use vagrant ssh
to get into the machine or use the GUI (if enabled).
For specific instructions please see the relevant example folders.
Folders are shared between the host machine and the VM by config.vm.synced_folder
instructions in the Vagrantfile (see documentation).
In case you want to execute a certain set of action when vagrant up
is called
for the first time (or vagrant provision
) you can use the config.vm.provision
instructions. E.g. to copy a file from the host machine:
config.vm.provision "file", source: "~/.gitconfig", destination: "/home/vagrant/.gitconfig"
or to execute shell commands
config.vm.provision "shell", inline: <<-SHELL
sudo mkdir /software
sudo chown vagrant /software
SHELL
Resource usage is controlled by the instructions
# RAM usage
vb.memory = "2048"
# CPU usage
vb.cpus = 2