Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
app_servers = {
:web1 => '192.168.1.101',
:web2 => '192.168.1.102'
}
Vagrant.configure("2") do |config|
config.vm.box = "centos6.5"
config.vm.define :static do |static_config|
static_config.vm.network :private_network, ip: "192.168.1.100"
static_config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.provider :virtualbox do |vb|
vb.name = "static_web"
vb.customize ["modifyvm", :id, "--memory", "256"]
end
end
app_servers.each do |app_server_name, app_server_ip|
config.vm.define app_server_name do |app_config|
app_config.vm.hostname = "#{app_server_name.to_s}.vagrant.internal"
app_config.vm.network :private_network, ip: app_server_ip
#app_config.vm.synced_folder "../app", "/opt/app"
app_config.vm.provider "virtualbox" do |vb|
vb.name = app_server_name.to_s
vb.customize ["modifyvm", :id, "--memory", "256"]
end
end
end
config.vm.define :mysql do |mysql_config|
mysql_config.vm.hostname = "mysql.vagrant.internal"
mysql_config.vm.network :private_network, ip: "192.168.1.103"
mysql_config.vm.provider "virtualbox" do |vb|
vb.name = "mysql"
vb.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
vb.customize ["modifyvm", :id, "--memory", "256"]
end
end
end
来源:oschina
链接:https://my.oschina.net/u/929212/blog/374472