Skip to content

Instantly share code, notes, and snippets.

@miguelcnf
Last active August 29, 2015 14:07
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 miguelcnf/bec5a20f7f78e680d7e5 to your computer and use it in GitHub Desktop.
Save miguelcnf/bec5a20f7f78e680d7e5 to your computer and use it in GitHub Desktop.
# -*- mode: ruby -*-
# vi: set ft=ruby :
boxes = {
:tomcat => {
:ipaddress => "172.31.254.110",
:role => "application"
},
:mysql => {
:ipaddress => "172.31.254.120",
:role => "database"
}
}
Vagrant::configure("2") do |global_config|
boxes.each_pair do |name, options|
global_config.vm.define name do |config|
ipaddress = options[:ipaddress]
role = options[:role]
if !Vagrant.has_plugin?("vagrant-omnibus")
error = "The vagrant-omnibus plugin is not installed! Try running:\nvagrant plugin install vagrant-omnibus"
raise Exception, error
end
if Vagrant.has_plugin?("vagrant-berkshelf")
config.berkshelf.enabled = true
else
error = "The vagrant-berkshelf plugin is not installed! Try running:\nvagrant plugin install vagrant-berkshelf"
raise Exception, error
end
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
config.vm.hostname = name.to_s
config.vm.box = "chef/fedora-20"
#config.vm.box_url = ""
config.vm.network :private_network, ip: ipaddress
config.vm.synced_folder "vagrant-root", "/vagrant", disabled: true
# using vagrant-omnibus plugin to install chef-solo
config.omnibus.chef_version = "latest"
config.vm.provision :chef_solo do |chef|
chef.custom_config_path = ".Vagrantfile.chef"
chef.roles_path = "chef/roles"
if role.eql? "application"
chef.add_role "tomcat"
elsif role.eql? "database"
chef.add_role "mysql"
end
end
config.vm.provider :virtualbox do |vb|
vb.customize [ "modifyvm", :id, "--memory", 512 ]
if role.eql? "application"
vb.customize [ "modifyvm", :id, "--cpus", 1 ]
elsif role.eql? "database"
vb.customize [ "modifyvm", :id, "--cpus", 2 ]
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment