Add WinRM over SSL support

This commit is contained in:
Peter Ericson 2014-06-03 13:49:19 +10:00 committed by Max Lincoln
parent 1c328914f8
commit a99d32f60a
4 changed files with 12 additions and 4 deletions

View File

@ -1,6 +1,8 @@
source "https://rubygems.org"
gemspec
# f4ece43: Allow the user to disable SSL peer verification.
gem 'winrm', git: 'https://github.com/WinRb/WinRM.git', ref: 'f4ece4384df2768bc7756c3c5c336db65b05c674'
if File.exist?(File.expand_path("../../vagrant-spec", __FILE__))
gem 'vagrant-spec', path: "../vagrant-spec"

View File

@ -111,6 +111,7 @@ module VagrantPlugins
port: winrm_info[:port],
timeout_in_seconds: @machine.config.winrm.timeout,
max_tries: @machine.config.winrm.max_tries,
ssl: @machine.config.winrm.ssl,
)
end

View File

@ -38,17 +38,19 @@ module VagrantPlugins
attr_reader :port
attr_reader :timeout_in_seconds
attr_reader :max_tries
attr_reader :ssl
def initialize(host, username, password, options = {})
@logger = Log4r::Logger.new("vagrant::communication::winrmshell")
@logger.debug("initializing WinRMShell")
@host = host
@port = options[:port] || 5985
@port = options[:port] || options[:ssl] ? 5986 : 5985
@username = username
@password = password
@timeout_in_seconds = options[:timeout_in_seconds] || 60
@max_tries = options[:max_tries] || 20
@ssl = options[:ssl] || false
end
def powershell(command, &block)
@ -119,6 +121,7 @@ module VagrantPlugins
@logger.info(" - Host: #{@host}")
@logger.info(" - Port: #{@port}")
@logger.info(" - Username: #{@username}")
@logger.info(" - SSL: #{@ssl}")
client = ::WinRM::WinRMWebService.new(endpoint, :plaintext, endpoint_options)
client.set_timeout(@timeout_in_seconds)
@ -131,7 +134,7 @@ module VagrantPlugins
end
def endpoint
"http://#{@host}:#{@port}/wsman"
"http#{@ssl ? 's' : ''}://#{@host}:#{@port}/wsman"
end
def endpoint_options
@ -140,7 +143,8 @@ module VagrantPlugins
host: @host,
port: @port,
operation_timeout: @timeout_in_seconds,
basic_auth_only: true }
basic_auth_only: true,
no_ssl_peer_verification: true }
end
end #WinShell class
end

View File

@ -28,7 +28,8 @@ Gem::Specification.new do |s|
s.add_dependency "rb-kqueue", "~> 0.2.0"
s.add_dependency "rest-client", ">= 1.6.0", "< 2.0"
s.add_dependency "wdm", "~> 0.1.0"
s.add_dependency "winrm", "~> 1.1.3"
# 1.1.4 (Unreleased)
#s.add_dependency "winrm", "~> 1.1.3"
# We lock this down to avoid compilation issues.
s.add_dependency "nokogiri", "= 1.6.3.1"