Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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