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.
On Thu, Jan 7, 2016 at 5:03 AM, Steven Iveson <[email protected]> wrote:
> 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.
>
> On Wednesday, 6 January 2016 04:41:00 UTC, Alvaro Miranda Aguilera wrote:
>>
>> 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
>>
>> On Wed, Jan 6, 2016 at 2:49 AM, Steven Iveson <[email protected]> wrote:
>>
>>> 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
>>>
>>> --
>>> 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/5bf96783-1343-48f3-a293-5e330b8537af%40googlegroups.com
>>> <https://groups.google.com/d/msgid/vagrant-up/5bf96783-1343-48f3-a293-5e330b8537af%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> 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/4bf8563c-f835-4ee2-92d8-f1b3f39d4011%40googlegroups.com
> <https://groups.google.com/d/msgid/vagrant-up/4bf8563c-f835-4ee2-92d8-f1b3f39d4011%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
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/CAHqq0eyOEKfAACYdufkfHFsYU5rZjOA4ibu_jOZdwm_-ibc7ww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Vagrantfile
Description: Binary data
