Skip to content

Instantly share code, notes, and snippets.

@MasahiroSakoda
Last active August 29, 2015 14:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MasahiroSakoda/27bd7f587812616cd7af to your computer and use it in GitHub Desktop.
Save MasahiroSakoda/27bd7f587812616cd7af to your computer and use it in GitHub Desktop.
Vagrant Tutorial

Vagrant Tutorial

Agenda

  • target
  • what is vagrant?
  • prepare
    • install VirutalBox
  • Install Vagrant
  • Create box
  • Initialize box
  • Launch Virtual Server
    • Login via SSH
  • Configure SSH settings
  • Shutdown Virtual Sever

Target

  • required Linux experience
    • command line
  • required SSH experience

What is Vagrant?

  • VirtualBox frontend
  • Multiplatform
    • Mac OS X
    • Windows
    • Linux
  • you can share development environment
  • integration with chef

Prepare

Create Vagrant Directory

$ mkdir -p ~/Vagrant/DevEnv
$ cd ~/Vagrant/DevEnv

Install VirtualBox

Install Vagrant

Create box

  • create box with following command
$ vagrant box create (box_name) (box_url)

Initialize box

  • init box with following command
$ vagrant init (box_name)

Launch virtual server

  • launch server with following command
$ vagrant up

Login via SSH

# Client
$ vagrant ssh

# logout Vagrant console
[vagrant@vagrant-(box_name) ~] $ exit

Configure SSH settings

  • To login with ssh (aliased_name), execute like this.
$ vagrant ssh-config —host aliased_name >> ~/.ssh/config

Shutdown Virtual Server

  • To shutdown server, execute following command
$ vagrant halt

Other Vagrant Commands

Remove box

$ vagrant box remove (box_name)

List box

$ vagrant box list

Check Vagrant status

$ vagrant status

Useful ways to use Vagrant

oh-my-zsh

  • oh-my-zsh vagrant plugin provides completion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment