Getting started with Vagrant

Vagrant has been getting a lot of attention, lately, for programming, testing, and lab’ing professionals. ┬áIt’s a VM controller that allows you to setup your infrastructure using a single configuration file named “Vagrantfile”.

In this video, I show you how to get started with Vagrant (does not show install), and at the end, how to spin up 2 VM’s (a web and db) while configuring IP Address, network, and hostname setting.

An example config is shown:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|

  config.vm.define "web" do |web|"ubuntu/trusty64"
    web.vm.hostname="web" "forwarded_port", guest: 80, host: 8080 "private_network", ip: ""
    web.vm.provision "ansible" do |ansible|
      ansible.playbook = "web-playbook.yml"
  config.vm.define "db" do |db|"ubuntu/trusty64"
  # config.vm.define "box3" do |box3|
  #   box3.vm.url=""
  #   box3.vm.hostname="box3"
  # end

The above Vagrantfile will spin up to VM’s, a “web” VM and a “db” VM, both using the Ubuntu Trusty64 image. To complete the example, I also show how to setup an Ansible auto-provision for “web” VM, using the ‘web-playbook.yml’ file.

Share This Page : Share on TwitterShare on FacebookShare on GooglePlusShare on PinterestShare on Linkedin