From d37eabb13dbbbf775053452fda5ce16481353995 Mon Sep 17 00:00:00 2001 From: sawanoboly Date: Fri, 17 May 2019 20:28:56 +0900 Subject: [PATCH 1/2] use WinRM::Connection for winrm >= 2.0 --- lib/serverspec/setup.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/serverspec/setup.rb b/lib/serverspec/setup.rb index 379621f7..06997cbd 100644 --- a/lib/serverspec/setup.rb +++ b/lib/serverspec/setup.rb @@ -308,8 +308,21 @@ def self.spec_helper_template pass = endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman" -winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true) -winrm.set_timeout 300 # 5 minutes max timeout for any operation +if Gem::Version.new(WinRM::VERSION) < Gem::Version.new('2') + winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true) + winrm.set_timeout 300 # 5 minutes max timeout for any operation +else + opts = { + user: user, + password: pass, + endpoint: endpoint, + operation_timeout: 300, + no_ssl_peer_verification: false, + } + + winrm = ::WinRM::Connection.new(opts) +end + Specinfra.configuration.winrm = winrm <% end -%> EOF From 7356fd5f05e2c3ac1c2a44f881a988688882c921 Mon Sep 17 00:00:00 2001 From: sawanoboly Date: Fri, 17 May 2019 20:31:20 +0900 Subject: [PATCH 2/2] update docs for d37eabb --- WINDOWS_SUPPORT.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/WINDOWS_SUPPORT.md b/WINDOWS_SUPPORT.md index 17bbee3e..e85054c7 100644 --- a/WINDOWS_SUPPORT.md +++ b/WINDOWS_SUPPORT.md @@ -26,8 +26,21 @@ user = pass = endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman" -winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true) -winrm.set_timeout 300 # 5 minutes max timeout for any operation +if Gem::Version.new(WinRM::VERSION) < Gem::Version.new('2') + winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true) + winrm.set_timeout 300 # 5 minutes max timeout for any operation +else + opts = { + user: user, + password: pass, + endpoint: endpoint, + operation_timeout: 300, + no_ssl_peer_verification: false, + } + + winrm = ::WinRM::Connection.new(opts) +end + Specinfra.configuration.winrm = winrm ```