Vishal Biyani
Vishal Biyani

Reputation: 4407

Specific VM name to target in a multi-VM environment

I am creating two CentOS Boxes with a Vagrantfile, and using two unique host names for them, in their respectibe blocks

box1_config.vm.host_name = "Base1"
box1_config.vm.network:hostonly, "192.168.50.4"

box2_config.vm.host_name = "Base2"
box2_config.vm.network:hostonly, "192.168.50.5"

The OS starts without any issues, but I don't know what hostname to use to access them.

I tried following as argument to "vagrant ssh", but none worked and I get error: "This command requires a specific VM name to target in a multi-VM environment"

Tried with:

Any clues where I might be going wrong?

Upvotes: 3

Views: 6205

Answers (1)

turtlebender
turtlebender

Reputation: 1907

The argument for vagrant ssh is the symbol attached to the vm definition block. For example (from the vagrant docs):

Vagrant::Config.run do |config|
  config.vm.define :web do |web_config|
    web_config.vm.box = "web"
    web_config.vm.forward_port 80, 8080
  end

  config.vm.define :db do |db_config|
    db_config.vm.box = "db"
    db_config.vm.forward_port 3306, 3306
  end
end

you would do

vagrant ssh web

or

vagrant ssh db

since those are the names of the box as defined in the config.

HTH.

Upvotes: 9

Related Questions