Vagrant 101 Workshop
You will learn
(WIIFM)
ā— What environments are
ā— What Infrastructure as a Code
(IaaC) is
ā— How to use Vagrant to spin off
an environment
Requirements ā— Basic knowledge of Linux
System
Requirements
ā— Latest version of Vagrant
installed
ā— Latest version of VirtualBox
installed
ā— Environment
ā— Vagrant introduction
ā— VirtualBox introduction
ā— Commands
ā— Workflow
Agenda
Environment
Hardware OS Middleware Application
PRODDEV STAGEDeployDeliver Deploy
Deployment Pipeline
Our DEV environment
ā— Got a Laptop
ā— Installed: Python, pip, virtualenv
ā— Checked out code from GitHub
ā— Hardware + OS
ā— Middleware
ā— Application
What Vagrant Is?
Building and Managing VM environments in a single,easy-to-
use workflow
https://www.vagrantup.com/
From Top
ā— Command line tool
ā— Providers: Virtualbox, VMWare, Hyper-V, AWS, GCP, Azure ….
ā— Provisioners: shell, Chef, Ansible, Puppet ….
ā— Runs on: Linux, Windows, MacOS
VirtualBox
ā— A general purpose full virtualizer for x86 hardware
ā— Free
ā— Open Source
ā— Available on every major platform
https://www.virtualbox.org
Getting up and running
$ vagrant init ubuntu/xenial64
$ vagrant up
$ vagrant ssh
Did you know?
Hashicorp is Vagrant vendor
Xenial = Ubuntu 16.04
Did you know?
ssh - Secure Shell. Used to log onto
remote systems
Command: vagrant init
Places a Vagrantfile is current directory
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
end
Run the init command in your
project root directory. Many
configuration options are relative to
the project root folder
ubuntu/xenial64 - a box
A box is a base image
Command: vagrant up
ā— The box is downloaded and stored locally in ~/.vagrant.d/boxes
ā— A new VM is created and bootstrapped with the box
ā— The VM is booted and provisioned
Command: vagrant ssh
ā— Log onto the VM
Did you know?
You logon with the user ā€˜vagrant’
which was created by vagrant
during the VM bootstrapping
Command: vagrant destroy
ā— Remove all traces of the guest machine from the host
machine
Command: vagrant box add
ā— Catalog - https://app.vagrantup.com/boxes/search
ā— Stored locally in ~/.vagrant.d/boxes
$ vagrant box add ubuntu/trusty64
Did you know?
Trusty = Ubuntu 14.04
Do you remember?
The base box configuration option is
in the Vagrantfile
Exercise
ā— Check which Ubuntu version is running - ā€˜lsb_release -a’
ā— Destroy the VM
ā— Spin up a new VM based on trusty64
ā— Check which Ubuntu version is running NOW
/vagrant - synced folder
ā— By default, the project root folder (host) is synced with the /vagrant folder
(guest)
ā— Two way sync
ā— It is not vagrant home directory
Provider - VirtualBox configuration
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox" do |v|
v.name = "my_vm"
v.memory = 2048
v.cpus = 4
end
end
Exercise
ā— Destroy current VM
ā— Spin up a new VM with different memory and cpu settings
ā— Check the new VM
ā— vagrant init user/box
ā— vagrant up
ā— vagrant destroy
ā— vagrant ssh
ā— vagrant box add user/box
Recap
shell provisioner
In the following Vagrant workshop

Vagrant 101 Workshop

  • 1.
  • 2.
    You will learn (WIIFM) ā—What environments are ā— What Infrastructure as a Code (IaaC) is ā— How to use Vagrant to spin off an environment
  • 3.
    Requirements ā— Basicknowledge of Linux
  • 4.
    System Requirements ā— Latest versionof Vagrant installed ā— Latest version of VirtualBox installed
  • 5.
    ā— Environment ā— Vagrantintroduction ā— VirtualBox introduction ā— Commands ā— Workflow Agenda
  • 6.
  • 7.
  • 8.
    Our DEV environment ā—Got a Laptop ā— Installed: Python, pip, virtualenv ā— Checked out code from GitHub ā— Hardware + OS ā— Middleware ā— Application
  • 10.
    What Vagrant Is? Buildingand Managing VM environments in a single,easy-to- use workflow https://www.vagrantup.com/
  • 11.
    From Top ā— Commandline tool ā— Providers: Virtualbox, VMWare, Hyper-V, AWS, GCP, Azure …. ā— Provisioners: shell, Chef, Ansible, Puppet …. ā— Runs on: Linux, Windows, MacOS
  • 12.
    VirtualBox ā— A generalpurpose full virtualizer for x86 hardware ā— Free ā— Open Source ā— Available on every major platform https://www.virtualbox.org
  • 13.
    Getting up andrunning $ vagrant init ubuntu/xenial64 $ vagrant up $ vagrant ssh Did you know? Hashicorp is Vagrant vendor Xenial = Ubuntu 16.04 Did you know? ssh - Secure Shell. Used to log onto remote systems
  • 14.
    Command: vagrant init Placesa Vagrantfile is current directory # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "ubuntu/xenial64" end Run the init command in your project root directory. Many configuration options are relative to the project root folder ubuntu/xenial64 - a box A box is a base image
  • 15.
    Command: vagrant up ā—The box is downloaded and stored locally in ~/.vagrant.d/boxes ā— A new VM is created and bootstrapped with the box ā— The VM is booted and provisioned
  • 16.
    Command: vagrant ssh ā—Log onto the VM Did you know? You logon with the user ā€˜vagrant’ which was created by vagrant during the VM bootstrapping
  • 17.
    Command: vagrant destroy ā—Remove all traces of the guest machine from the host machine
  • 18.
    Command: vagrant boxadd ā— Catalog - https://app.vagrantup.com/boxes/search ā— Stored locally in ~/.vagrant.d/boxes $ vagrant box add ubuntu/trusty64 Did you know? Trusty = Ubuntu 14.04 Do you remember? The base box configuration option is in the Vagrantfile
  • 19.
    Exercise ā— Check whichUbuntu version is running - ā€˜lsb_release -a’ ā— Destroy the VM ā— Spin up a new VM based on trusty64 ā— Check which Ubuntu version is running NOW
  • 20.
    /vagrant - syncedfolder ā— By default, the project root folder (host) is synced with the /vagrant folder (guest) ā— Two way sync ā— It is not vagrant home directory
  • 21.
    Provider - VirtualBoxconfiguration # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant.configure("2") do |config| config.vm.box = "ubuntu/xenial64" config.vm.provider "virtualbox" do |v| v.name = "my_vm" v.memory = 2048 v.cpus = 4 end end
  • 22.
    Exercise ā— Destroy currentVM ā— Spin up a new VM with different memory and cpu settings ā— Check the new VM
  • 23.
    ā— vagrant inituser/box ā— vagrant up ā— vagrant destroy ā— vagrant ssh ā— vagrant box add user/box Recap
  • 25.
    shell provisioner In thefollowing Vagrant workshop