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|
web.vm.box="ubuntu/trusty64"
web.vm.hostname="web"
web.vm.network "forwarded_port", guest: 80, host: 8080
web.vm.network "private_network", ip: "192.168.33.10"
web.vm.provision "ansible" do |ansible|
ansible.playbook = "web-playbook.yml"
end
end
config.vm.define "db" do |db|
db.vm.box="ubuntu/trusty64"
db.vm.hostname="db"
end
# config.vm.define "box3" do |box3|
# box3.vm.url="http://myteneo.net/boxes/my_box.box"
# box3.vm.box="my_box"
# box3.vm.hostname="box3"
# end
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.