Skip to content

Instantly share code, notes, and snippets.

@elfarsaouiomar
Created August 25, 2022 06:19
Show Gist options
  • Save elfarsaouiomar/47feea364dc0de86c0b6147a06eef89d to your computer and use it in GitHub Desktop.
Save elfarsaouiomar/47feea364dc0de86c0b6147a06eef89d to your computer and use it in GitHub Desktop.
Multiple Vagrant VMs in One Vagrantfile
Vagrant.configure("2") do |config|
config.vm.define "web" do |web|
web.vm.box = "precise64"
web.vm.hostname = 'web'
web.vm.box_url = "ubuntu/trusty64"
web.vm.network :private_network, ip: "192.168.56.101"
web.vm.network :forwarded_port, guest: 22, host: 10122, id: "ssh"
web.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--memory", 512]
v.customize ["modifyvm", :id, "--name", "web"]
end
end
config.vm.define "db" do |db|
db.vm.box = "precise64"
db.vm.hostname = 'db'
db.vm.box_url = "ubuntu/precise64"
db.vm.network :private_network, ip: "192.168.56.102"
db.vm.network :forwarded_port, guest: 22, host: 10222, id: "ssh"
db.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--memory", 512]
v.customize ["modifyvm", :id, "--name", "db"]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment