vagrant up on Vagrantfile with multiple hosts launches all vms on one host

389 views
Skip to first unread message

Aaron Palumbo

unread,
Dec 4, 2015, 3:31:40 PM12/4/15
to Vagrant
also posted on stack overflow

I have a Vagrant file that I want to use to launch 3 VMs on three separate hosts. If I run

    vagrant up master
    vagrant up slave1
    vagrant up slave2

things work as expected; I get my three VMs running on three different hosts.

However, if I just run

    vagrant up

I end up with all the machines on one host. There are similar issues with vagrant destroy.

Am I doing something wrong? Is there a flag I need to set?

My setup:  

- I'm running vagrant from a Ubuntu 14.04LTS desktop.
- provider = libvirt
- I used vagrant-mutate to make the box libvirt compatible
- vagrant version 1.7.4
- VAGRANT_DEFAULT_PROVIDER=libvirt is set in my .bashrc

Hosts:

- Ubuntu Server 14.04LTS

I can expand on this if necessary, but it seems like the problem is something I'm doing in vagrant; somehow it's only using the .provider section once???

Vagrantfile:

    # -x- mode: ruby -x-
   
# vi: set ft=ruby :
   
    boxes
= [
       
{
           
:name => "master",
           
:host => "192.168.1.21",
           
:hostname => "hibanako-1",
           
:mac => "..."
       
},
       
{
           
:name => "slave1",
           
:host => "192.168.1.22",
           
:hostname => "hibanako-2",
           
:mac => "..."
       
},
       
{
           
:name => "slave2",
           
:host => "192.168.1.23",
           
:hostname => "hibanako-3",
           
:mac => "..."
       
}
   
]
   
    VAGRANT_API_VERSION
= "2"
   
   
   
Vagrant.configure(VAGRANT_API_VERSION) do |config|
      boxes
.each do |opts|
        config
.vm.define opts[:name] do |boxconfig|
   
          boxconfig
.vm.box = "ubuntu/trusty64"
          boxconfig
.vm.hostname = opts[:hostname]
          boxconfig
.vm.network :public_network,
           
:dev => "p2p1",
           
:mac => opts[:mac],
           
:mode => 'bridge'
          boxconfig
.vm.provider :libvirt do |lv|
            lv
.host = opts[:host]
            lv
.username = "..."
            lv
.connect_via_ssh = true
            lv
.memory = 1600
            lv
.cpus = 4
         
end
       
end
     
end
   
end


Some of the resources I've looked at:

- (I'm sure there are others ...)

Alvaro Miranda Aguilera

unread,
Dec 5, 2015, 2:59:08 AM12/5/15
to vagra...@googlegroups.com
Hello,

You have 3 computers. (host)

then, you should use separate Vagrantfiles.

If you have a multi-vm file, and it's the same file (shared folder)
you may hit issues.

I think is working as espected at the moment.

You can override some of the options, but you would end having
different files for each host, so will be easier to manage having
separate Vagrantfile

Thanks
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+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vagrant-up/da14e89e-bde0-47f1-8b37-6684a58c48a9%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Joaquin Menchaca

unread,
Dec 5, 2015, 4:43:45 PM12/5/15
to Vagrant



You have 3 computers. (host)

then, you should use separate Vagrantfiles.


That's not needed.  I have one vagrantfile for 3 different systems, and I have no problem.

In my setup, I used Virtualbox default provider, and did

Vagrant.configure("2") do |config|
  config.vm.define "chefserver" do |chefserver|
         chefserver.vm.network "private_network", ip: "#{ipaddr['chefserver']}"
  end

  config.vm.define "workstation" do |workstation|
         workstation.vm.network "private_network", ip: "#{ipaddr['workstation']}"
  end

  config.vm.define "node" do |node|
         node.vm.network "private_network", ip: "#{ipaddr['node']}"
  end   
end


For testing, I would see if it works in VirtualBox, then if it does, then back to libvrt...
Reply all
Reply to author
Forward
0 new messages