Open rushi47 opened 2 years ago
Heya thanks for opening up an issue!
One way to change the current Vagrant context is to use the VAGRANT_CWD environment variables. When set it will execute a Vagrant command as if Vagrant was running in another folder. So please ensure that VAGRANT_CWD is not set.
However, it looks like Vagrant is ssh'ing into the correct machines. From the output of the vagrant port
commands provided, it looks like both machines get their own distinct port forwards for ssh. The vagrant ssh
command seems to execute successfully. From the output provided it's hard to tell if vagrant is ssh'ing into the right machine since both are host names are set to 'build' in the Vagrantfiles and both machines are using the same box. So, I tried to recreate the issue, but set different hostnames for the machines so it would be more obvious if Vagrant was ssh'ing into the correct machine. Here they are:
In folder ~/project/dbl-test/one
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/bionic64"
config.vm.hostname = "build-one"
config.vm.define "buildServer"
config.vm.provider :vmware_fusion do |v, o|
v.gui = true
v.memory = 4024
v.cpus = 4
end
end
In folder ~/project/dbl-test/two
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/bionic64"
config.vm.hostname = "build-two"
config.vm.define "buildServer"
config.vm.provider :vmware_fusion do |v, o|
v.gui = true
v.memory = 4024
v.cpus = 4
end
end
Then I can vagrant up and ssh into the machine: from ~/project/dbl-test/one
% vagrant ssh
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-58-generic x86_64)
# ... excluded for brevity ...
vagrant@build-one:~$
from ~/project/dbl-test/two
% vagrant ssh
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-58-generic x86_64)
# ... excluded for brevity ...
vagrant@build-two:~$
If this issue persists after checking for VAGRANT_CWD, could you please share a bit more debug info. In particular it would be helpful if you
config.vm.hostname
to different names (so that the guest you are ssh'ing to is more easily identified)vagrant ssh
in both foldersglobal-status
Thanks!
Hey @soapy1
Thanks for writing it out and sorry for late reply.
I changed hostname
already but still encountering the issue below are vagrant files for both the machines :
One named build
rushi@Rushikeshs-MacBook-Air demoMachine % cat Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "bytesguy/ubuntu-server-20.04-arm64"
config.vm.box_version = "1.0.0"
config.vm.hostname = "build"
config.vm.define "buildServer"
config.vm.provider :vmware_fusion do |v, o|
v.gui = true
v.memory = 4024
v.cpus = 4
end
config.vm.synced_folder "/-excluded-/LKP/sharedFolder","/home/vagrant/shared"
end
Other is main
rushi@Rushikeshs-MacBook-Air uvagrant % cat Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "bytesguy/ubuntu-server-20.04-arm64"
config.vm.box_version = "1.0.0"
config.vm.define "main"
config.vm.provider :vmware_fusion do |v, o|
v.gui = true
v.memory = 4024
v.cpus = 4
end
config.vm.synced_folder "sharedFolder","/home/vagrant/localshared"
config.vm.synced_folder "/-excluded-/LKP/sharedFolder","/home/vagrant/shared"
end
Vagrant global status
rushi@Rushikeshs-MacBook-Air demoMachine % vagrant global-status
id name provider state directory
-----------------------------------------------------------------------------------------------
f0e25da default vmware_fusion running /-excluded-/LKP/uvagrant
5fcd8c3 buildServer vmware_fusion running /-excluded-/LKP/demoMachine
c0dcfe1 main vmware_fusion running /-excluded-/LKP/uvagrant
The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date (use "vagrant global-status --prune" to prune invalid
entries). To interact with any of the machines, you can go to that
directory and run Vagrant, or you can use the ID directly with
Vagrant commands from any directory. For example:
"vagrant destroy 1a2b3c4d"
Logs attached.
ps: ssh seems to hang on terminal when it was run with debug command : vagrant ssh --debug &> demo_machine.log
demo_machine.log
main_machine.log
@chrisroberts Hey, feel free to remove label waiting-reply
from this one.
Thanks :)
Debug output
Expected behavior
I have two Boxes running in different directories
uvagrant
anddemoMachine
(as shown in the output), when both of my boxes are running vagrant confuses while doingssh
even if I run from their respective directories. If Issh
inuvagrant
machine it will go todemomachine
, above is the output in debug log.Normally it should go to their respective machines, even if I use the machine names it still goes into different machines.
Actual behavior
Whenever I am trying to
ssh
into machine located inuvagrant
directory will ssh into Machine located indemoMachine
. Looks likessh
runs in conflict.Reproduction information
Vagrant version
Host operating system
Guest operating system
Steps to reproduce
Vagrantfile
Machine-1
Machine-2
Port host op :