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 ``` 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