Skip to content

Instantly share code, notes, and snippets.

@christophchamp
Created June 28, 2016 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christophchamp/da619ac4482bc42d9d9fb49e9bc6de7b to your computer and use it in GitHub Desktop.
Save christophchamp/da619ac4482bc42d9d9fb49e9bc6de7b to your computer and use it in GitHub Desktop.
Spin up multiple Vagrant VMs
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
$common_script = <<COMMON_SCRIPT
# Set verbose
set -v
# Set exit on error
set -e
echo -e "$(date) [INFO] Starting modified Vagrant..."
sudo yum update -y
# Install extra tools useful for troubleshooting:
sudo yum install -y bind-utils nmap tcpdump traceroute telnet mtr strace \
nc net-tools bash-completion
# Timestamp provision
date > /etc/vagrant_provisioned_at
COMMON_SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/centos-6.7"
config.vm.synced_folder "data", "/vagrant", disabled: false
## VM: webserver ##################################################
config.vm.define "webserver" do |webserver|
webserver.vm.hostname = "web1.dev"
webserver.vm.provision "shell", inline: $common_script
webserver.vm.network "forwarded_port", guest: 80, host: 8080
webserver.vm.provider "virtualbox" do |vbox|
vbox.customize ["modifyvm", :id, "--memory", "4096"]
vbox.customize ["modifyvm", :id, "--cpus", "2"]
end
end
## VM: dbserver ###################################################
config.vm.define "dbserver" do |dbserver|
dbserver.vm.hostname = "db1.dev"
dbserver.vm.provision "shell", inline: $common_script
dbserver.vm.provider "virtualbox" do |vbox|
vbox.customize ["modifyvm", :id, "--memory", "4096"]
vbox.customize ["modifyvm", :id, "--cpus", "2"]
end
end
###################################################################
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment