jamiemoore / vagrant-examples

Examples of vagrant configuration

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vagrant Examples

This project contains example vagrant projects running vex (its awesome!).

  • single-centos7 - Single Virtual Machine running the application vex
  • multi-centos7 - Multiple virtual machines running centos7
  • docker-vm - Docker Example using a centos7 virtual machine

Single

Single Virtual Machine controlled by vagrant running the vex application.

http://vex

Multi

Point your browser to http://proxy/ and refresh the browser, you should see the proxy round robin between web01 and web02.

Docker

Docker example using a Ubuntu 14.04 docker host

Vagrant Installation

  1. Install virtualbox/vmware player/docker

  2. Install vagrant from www.vagrantup.com

  3. Install hostmanager vagrant plugin

    vagrant plugin install vagrant-hostmanager
  4. Install the vagrant triggers plugin

    vagrant plugin install vagrant-triggers

Useful Vagrant Commands

#Check the status of the virtual machines in the current directory
vagrant status
#Start the virtual machines
vagrant up
#ssh to your virtual machines
vagrant ssh
#ssh to a specific vm if you have multiple vms in the vagrant file
vagrant ssh vm_name
#Poweroff the virtual machines
vagrant halt
#Re-run the provision scripts
vagrant provision
#Check the status of all virtual machines
vagrant global-status
#Reconfigure your hosts file
vagrant hostmanager
#Reconfigure hosts file when using non default provider
$VAGRANT_DEFAULT_PROVIDER="virtualbox" vagrant hostmanager
#Delete your virtual machines
vagrant destroy
#Delete without prompting
vagrant destroy -f
#Update your plugins
vagrant plugin update
#Remove obsolete machines 
vagrant global-status --prune
#Update your vagrant boxes to the latest version
vagrant box update

Notes

  • When you clone your repo make sure you ignore the files inside the .vagrant directory
cat .gitignore 
.vagrant
  • Vagrant hostmanager plugin (1.5.0) can't get dhcp ip addresses without the configuration found in the sample vagrant files
  • Vagrant VMWare plugin does not always create new networks correctly. So it is better to use dhcp rather than setting a static private address.
  • The order virtual machines are created may be important. For example if your provisioning scripts depend on other vms then they should be created first. ie database hosts, web hosts and proxies last
  • In vagrant (1.7.2) there is a bug, fixed in (1.7.3) that means if you are using virtualbox and receive an error about "a host only network interface attempting to configure via DHCP" you should run the following command as yourself:
VBoxManage dhcpserver remove --netname HostInterfaceNetworking-vboxnet0

About

Examples of vagrant configuration


Languages

Language:Ruby 69.2%Language:Python 21.8%Language:Shell 9.0%