Multi-machine Vagrant file to use one VM?

50 views
Skip to first unread message

Gregory Schultz

unread,
Oct 6, 2016, 9:57:57 PM10/6/16
to Vagrant
Hello,

I design websites and would like to start using multi-machine setup. Is it possible to use one VM for each config in a multi-machine setup? I don't need all VMs on at the same time, just one at a time. Each config file loads the sync folder.

This is my Vagrantfile so far:

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network :forwarded_port, host: 8080, guest: 80
config.vm.network "private_network", ip: "172.28.128.3"

config.vm.define "myoffercode" do |vm1|
    vm1.vm.synced_folder "/Users/gregoryschultz/Sites/myoffercode", "/var/www/html"
end

config.vm.define "dailybayou" do |vm2|
    vm2.vm.synced_folder "/Users/gregoryschultz/Sites/dailybayou", "/var/www/html"
end
end

Rui Lopes

unread,
Oct 8, 2016, 1:39:30 PM10/8/16
to Vagrant
Instead of a single Vagrantfile for all of your projects, why don't you have a Vagrantfile inside of each of those projects? Its simpler that way, and you just need to go into the project directory and do a simple vagrant up.

Anyways, if you really want to use a single Vagrantfile, I don't quite understood you. Do you want to share the config.vm between the VMs and only change the synced_folder? if so, its a matter of placing the configuration outside the config.vm.define blocks.

Alvaro Miranda Aguilera

unread,
Oct 9, 2016, 2:26:17 PM10/9/16
to vagra...@googlegroups.com
Usually the Vagrantfile lives with the code, so is part of the version control, the provisioning scripts to create the VM can be used later to deploy the app/code into production, etc.

If you want to have a big Vagrantifile like that, it will work, there is a way to stop the VMs starting if you do a vagrant up, add  autostart: false to the define.

At the end, use what ever make more sense for your workflow :)

Alvaro.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/1e56affb-53ae-44b0-910c-2b37d8b2f066%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages