Skip to content

Commit

Permalink
use WinRM::Connection for winrm >= 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sawanoboly committed May 17, 2019
1 parent 4807589 commit d37eabb
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/serverspec/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,21 @@ def self.spec_helper_template
pass = <password>
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
Expand Down

0 comments on commit d37eabb

Please sign in to comment.