Skip to content

[CEMRACS] Create and import a Vagrant box

Alexandre Ancel edited this page Jul 11, 2016 · 8 revisions

Create a vagrant box

  • Write the required Vagrantfile to build the virtual machine and build it
  • Create the box using the following command:
vagrant package --base "CEMRACS-2016"

with --base specifies the virtual machine name (e.g. for VirtualBox, the name that has been set with vb.name or the one displayed in the interface of VirtualBox)

Import the vagrant box

  • Import the image from the box file and name it:
vagrant box add CEMRACS-2016 ./package.box
  • Check if the image has been correctly imported:
vagrant box list
  • Create a base Vagrantfile for the image to launch:
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.vm.box = "CEMRACS-2016"

  # Tell vagrant how it can login  
  config.ssh.username = "ubuntu"
  config.ssh.password = "cemracs"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  config.vm.synced_folder ".", "/vagrant_data"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true

    # Customize the amount of memory on the VM:
    vb.memory = "1024"
    # Customize the number of processors available
    vb.cpus = "2"
  end
end

If you prefer to start from zero, you can also create an empty Vagrantfile with vagrant init CEMRACS-2016

  • Load the VM from the box and start it with:
vagrant up