1

I've set up 4 VMs in Vagrant and now trying to set the name of a VM in Vagrant as I don't just want to ssh into the default VM.

I can't find any docs on the vagrant website but found this:

How to change Vagrant 'default' machine name?

However, when I try:

config.vm.define "foohost"

and do a vagrant up I get:

There are errors in the configuration of this machine. Please fix
the following errors and try again:

vm:
* The following settings shouldn't exist: define
Snowcrash
  • 80,579
  • 89
  • 266
  • 376
  • 1
    The answer you are linking to is correct. Are you adding only the line with `define` or also the lines around it, as explained in the linked answer ? If you don't show all the code, we cannot help. Are you familiar with https://stackoverflow.com/help/mcve ? – marco.m Sep 07 '18 at 19:16

2 Answers2

1

I suspect you actually wrote

config.vm.define = "foohost"

rather than

config.vm.define "foohost"

as that would explain the error message. (Best to show several lines of actual source if you can.)

Jon Knox
  • 21
  • 3
0

as I don't just want to ssh into the default VM.

so when you use multiple VM, you can tell vagrant which VM you want to ssh by default, using the following

config.vm.define "foohost", primary: true do |foohost|
    ...
end

then when you run vagrant ssh you will ssh by default in this VM. To ssh into the other MV, you will need to specify the VM name

Frederic Henri
  • 51,761
  • 10
  • 113
  • 139