Last active
August 29, 2015 14:07
-
-
Save miguelcnf/bec5a20f7f78e680d7e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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