Skip to content

Instantly share code, notes, and snippets.

@tknerr
Created July 30, 2014 06:16
Show Gist options
  • Select an option

  • Save tknerr/53f7b30e41eea15dc892 to your computer and use it in GitHub Desktop.

Select an option

Save tknerr/53f7b30e41eea15dc892 to your computer and use it in GitHub Desktop.
Sample Workshop Excercise

Vagrant Basic Commands

Goal

Getting familiar with the Vagrant commandline interface

Excercise!

  • list the subcommands vagrant has
  • show the help / usage instructions for vagrant init
  • create a new Vagrantfile in the playground
  • check if vagrant up already brings up a VM
  • list the available base boxes
  • fix the Vagrantfile by adding a base box and try to bring up the VM again
  • check the status of the VM
  • open the VirtualBox GUI and check if you can see the VM running here as well
  • configure the display name for the VM in VirtualBox GUI
  • ssh into the VM and check on which operation system you are
  • leave the ssh session and destroy the VM
  • check the status again via Vagrant and VirtualBox

Hints

I ran the following commands:

  • vagrant -h to list the available subcommands
  • vagrant init -h to show the help for vagrant init
  • vagrant init --minimal to create the Vagrantfile (don't like the comments)
  • ran vagrant up but it failed :-(
  • vagrant box list to list the available base boxes
  • added "opscode_ubuntu-12.04-i386_provisionerless" as the config.vm.box
  • ran vagrant up and it worked! :-)
  • vagrant status tells me that it's the default VM and that it is running
  • opened VirtualBox from the start menu, and saw a VM named "solution_default_14037673" running
  • set the display name to "00-vagrant-basic-commands" in the virtualbox specific provider settings (see here: https://docs.vagrantup.com/v2/virtualbox/configuration.html)
  • vagrant ssh brought me right into the VM, cat /etc/lsb-release shows me it's Ubuntu 12.04
  • exit closed the ssh session, then I ran vagrant destroy -f to destroy the VM
  • vagrant status says it's "not created" and I saw it disappear from VirtualBox when I destroyed it earlier
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# name of the basebox to be used
config.vm.box = "opscode_ubuntu-12.04-i386_provisionerless"
# setting the display name shown in the VirtualBox GUI
config.vm.provider "virtualbox" do |v|
v.name = "00-vagrant-basic-commands"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment