VirtualBox Guest Name Incorrect

25 views
Skip to first unread message

Steven Iveson

unread,
Jan 5, 2016, 8:49:27 AM1/5/16
to Vagrant
Hi all,

I'm trying to launch a multi-machine environment but find that the first guest launched (specified as server in the Vagrantfile) actually gets the name rancher-host-02, thus causing the launch of that second (and the third) guest to fail as another guest has the same name. 

I've tried being as explicit as possible in the Vagrantfile (rather than use a variable) without success. I've also tried to separate the machine specifications by using two Vagrant.configure sections, again without success. 

I assume there's something about how the file is parsed that I'm not aware of, or perhaps the loop for the host-01/host-02 guests is wrong in some way?

If I specify 'vagrant up server' the guest is named as expected.

I've also tried deleting cache/d files here:

- C:\Users\...\$where_my_vagrantfile_lives\.vagrant\machines
- C:\Users\$User_name\.vagrant.d\data\...

Windows: 7
Vagrant: I've tried 1.7.4 and 1.8.1
VirtualBox: 5.0.12

My Vagrantfile, plus the rancher plugin are both attached. I have searched this group for similar issues and not found any (although its been educational regardless).

If anyone can help I'd be very grateful. TIA
rancher_guest_plugin.rb
Vagrantfile

Alvaro Miranda Aguilera

unread,
Jan 5, 2016, 11:41:00 PM1/5/16
to vagra...@googlegroups.com
Hello.

Please have this following Vagranfile as example.

run `vagrant status` and you will see will show 5 VMs

you can adjust the number and name, and use it as base.

Hope this helps

# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!

Vagrant.configure("2") do |config|

  config.vm.box = "hashicorp/precise64"

  #agent box

  (1..5).each do |i|

    vm_name = "agent#{i}"

    config.vm.define vm_name do |agent|

      agent.vm.hostname = vm_name

    end

  end

end


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/5bf96783-1343-48f3-a293-5e330b8537af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steven Iveson

unread,
Jan 6, 2016, 11:03:02 AM1/6/16
to Vagrant
Thanks Alvaro,

This however doesn't help. I want one guest to have a completely different name (and other settings) to the the subsequent ones, rather than a number of hosts with names where only a number changes between them and other settings are the same. I'm actually using the technique you describe for the second and third guests.

Also, I'm referring to the VirtualBox guest name that is incorrect, not the Vagrant name (which is used correctly).

Thanks.

Alvaro Miranda Aguilera

unread,
Jan 8, 2016, 7:11:33 PM1/8/16
to vagra...@googlegroups.com
Hello,

I am confused on what name you are after. Can you explain?

The hostname will be config.vm.hostname

The name in the GUI of virtualbox, will be:

 config.vm.provider :virtualbox do |vb|

        vb.name = vm_name 

end



For having names in the ruby block,  you can try this:

["alpha", "beta"].to_enum.with_index(1).each do |vm_name, i|

    config.vm.define vm_name do |agent|

      agent.vm.hostname = vm_name

      agent.vm.provider :virtualbox do |vb|

        vb.name = vm_name 

      end

    end

end

Attached sample Vagrantfile

i will include the index, that can be used for the IP

ip = "192.168.33.#{10+i}"

Alvaro.

Vagrantfile
Reply all
Reply to author
Forward
0 new messages