Snowcrash
Snowcrash

Reputation: 86337

How do you set the VM name via Vagrant?

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

Upvotes: 1

Views: 1130

Answers (2)

Jon Knox
Jon Knox

Reputation: 21

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.)

Upvotes: 1

Frederic Henri
Frederic Henri

Reputation: 53793

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

Upvotes: 0

Related Questions