From 3bff55034a846af7d5ceab8d7ff020bad9cf0f61 Mon Sep 17 00:00:00 2001 From: Kierran McPherson Date: Wed, 4 May 2016 12:04:25 +1200 Subject: [PATCH 1/2] kernel/v2: Reimplement 8655d21 to always forward SSH Fixes #7202 Always forwards SSH even if WinRM is set --- plugins/kernel_v2/config/vm.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 13e0102bd..378c7eb3c 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -425,7 +425,9 @@ module VagrantPlugins id: "winrm-ssl", auto_correct: true end - elsif !@__networks["forwarded_port-ssh"] + end + # forward SSH ports regardless of communicator + if !@__networks["forwarded_port-ssh"] network :forwarded_port, guest: 22, host: 2222, From 4afe0478b8ca6821f23591453cbbe34ad9a72665 Mon Sep 17 00:00:00 2001 From: Kierran McPherson Date: Wed, 4 May 2016 14:00:18 +1200 Subject: [PATCH 2/2] Fix broken test; Add explicit test Hopefully the explicit test will prevent this from being regressed again in the future --- test/unit/plugins/kernel_v2/config/vm_test.rb | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/test/unit/plugins/kernel_v2/config/vm_test.rb b/test/unit/plugins/kernel_v2/config/vm_test.rb index 992c27716..28a4688a6 100644 --- a/test/unit/plugins/kernel_v2/config/vm_test.rb +++ b/test/unit/plugins/kernel_v2/config/vm_test.rb @@ -173,7 +173,7 @@ describe VagrantPlugins::Kernel_V2::VMConfig do subject.communicator = "winrm" subject.finalize! n = subject.networks - expect(n.length).to eq(2) + expect(n.length).to eq(3) expect(n[0][0]).to eq(:forwarded_port) expect(n[0][1][:guest]).to eq(5985) @@ -188,6 +188,32 @@ describe VagrantPlugins::Kernel_V2::VMConfig do expect(n[1][1][:id]).to eq("winrm-ssl") end + it "forwards ssh even if the communicator is winrm" do + subject.communicator = "winrm" + subject.finalize! + n = subject.networks + expect(n.length).to eq(3) + + expect(n[0][0]).to eq(:forwarded_port) + expect(n[0][1][:guest]).to eq(5985) + expect(n[0][1][:host]).to eq(55985) + expect(n[0][1][:host_ip]).to eq("127.0.0.1") + expect(n[0][1][:id]).to eq("winrm") + + expect(n[1][0]).to eq(:forwarded_port) + expect(n[1][1][:guest]).to eq(5986) + expect(n[1][1][:host]).to eq(55986) + expect(n[1][1][:host_ip]).to eq("127.0.0.1") + expect(n[1][1][:id]).to eq("winrm-ssl") + + expect(n[2][0]).to eq(:forwarded_port) + expect(n[2][1][:guest]).to eq(22) + expect(n[2][1][:host]).to eq(2222) + expect(n[2][1][:host_ip]).to eq("127.0.0.1") + expect(n[2][1][:id]).to eq("ssh") + + end + it "allows overriding SSH" do subject.network "forwarded_port", guest: 22, host: 14100, id: "ssh"