tets
Vagrant.configure("2") do |config|¬
··settings['hosts'].each do |hostname, ipaddr|¬
····default = settings['defaults'][hostname] || false¬
····config.vm.define hostname, primary: default do |node|¬
······node.vm.box = "ubuntu/trusty64"¬
······node.vm.hostname = "#{hostname}"¬
······node.vm.network "private_network", ip: ipaddr¬
······node.vm.provider("virtualbox") { |vbox| vbox.name = "#{hostname}_#{
time}" }¬
······if settings['ports'][hostname]¬
········settings['ports'][hostname].each do |forward|¬
··········node.vm.network "forwarded_port", guest: forward['guest'], host: 
forward['host']¬
········end¬
······end¬
······# Provision¬
······node.vm.provision "shell", path: "scripts/setup-all.sh"¬
······node.vm.provision "shell", path: "scripts/#{hostname}.sh"¬
····end¬
··end¬
end

test

On Sunday, April 24, 2016 at 12:53:51 AM UTC-7, Joaquin Menchaca wrote:
>
> The docs <https://www.vagrantup.com/docs/multi-machine/> say, for making 
> one machine a primary, you can do:
>
> config.vm.define "web", primary: true do |web|
>   # ...end
>
>
> How do you do it, if you bring these up dynamically, such as a hosts file? 
>
> nodes = Hash.new
> File.readlines('config/global.hosts').map(&:chomp).each do |line|
>   ipaddr, nodename = line.split(" ")
>   nodes[nodename] = ipaddr
> end
>
> Vagrant.configure("2") do |config|
>   nodes.each do |nodename, ipaddr|
>     config.vm.define nodename do |node|
>       node.vm.box = "ubuntu/trusty64"
>       node.vm.hostname = "#{nodename}"
>       node.vm.network "private_network", ip: ipaddr
>       node.vm.provider("virtualbox") { |vbox| vbox.name = "#{nodename}" }
>       node.vm.provision "shell", path: "scripts/#{nodename}.sh"
>     end
>   end
> end 
>
>
>
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vagrant-up/feb6374b-aee2-4730-a996-14cc8d32f4b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to