Add WinRM over SSL support
This commit is contained in:
parent
1c328914f8
commit
a99d32f60a
2
Gemfile
2
Gemfile
|
@ -1,6 +1,8 @@
|
||||||
source "https://rubygems.org"
|
source "https://rubygems.org"
|
||||||
|
|
||||||
gemspec
|
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__))
|
if File.exist?(File.expand_path("../../vagrant-spec", __FILE__))
|
||||||
gem 'vagrant-spec', path: "../vagrant-spec"
|
gem 'vagrant-spec', path: "../vagrant-spec"
|
||||||
|
|
|
@ -111,6 +111,7 @@ module VagrantPlugins
|
||||||
port: winrm_info[:port],
|
port: winrm_info[:port],
|
||||||
timeout_in_seconds: @machine.config.winrm.timeout,
|
timeout_in_seconds: @machine.config.winrm.timeout,
|
||||||
max_tries: @machine.config.winrm.max_tries,
|
max_tries: @machine.config.winrm.max_tries,
|
||||||
|
ssl: @machine.config.winrm.ssl,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -38,17 +38,19 @@ module VagrantPlugins
|
||||||
attr_reader :port
|
attr_reader :port
|
||||||
attr_reader :timeout_in_seconds
|
attr_reader :timeout_in_seconds
|
||||||
attr_reader :max_tries
|
attr_reader :max_tries
|
||||||
|
attr_reader :ssl
|
||||||
|
|
||||||
def initialize(host, username, password, options = {})
|
def initialize(host, username, password, options = {})
|
||||||
@logger = Log4r::Logger.new("vagrant::communication::winrmshell")
|
@logger = Log4r::Logger.new("vagrant::communication::winrmshell")
|
||||||
@logger.debug("initializing WinRMShell")
|
@logger.debug("initializing WinRMShell")
|
||||||
|
|
||||||
@host = host
|
@host = host
|
||||||
@port = options[:port] || 5985
|
@port = options[:port] || options[:ssl] ? 5986 : 5985
|
||||||
@username = username
|
@username = username
|
||||||
@password = password
|
@password = password
|
||||||
@timeout_in_seconds = options[:timeout_in_seconds] || 60
|
@timeout_in_seconds = options[:timeout_in_seconds] || 60
|
||||||
@max_tries = options[:max_tries] || 20
|
@max_tries = options[:max_tries] || 20
|
||||||
|
@ssl = options[:ssl] || false
|
||||||
end
|
end
|
||||||
|
|
||||||
def powershell(command, &block)
|
def powershell(command, &block)
|
||||||
|
@ -119,6 +121,7 @@ module VagrantPlugins
|
||||||
@logger.info(" - Host: #{@host}")
|
@logger.info(" - Host: #{@host}")
|
||||||
@logger.info(" - Port: #{@port}")
|
@logger.info(" - Port: #{@port}")
|
||||||
@logger.info(" - Username: #{@username}")
|
@logger.info(" - Username: #{@username}")
|
||||||
|
@logger.info(" - SSL: #{@ssl}")
|
||||||
|
|
||||||
client = ::WinRM::WinRMWebService.new(endpoint, :plaintext, endpoint_options)
|
client = ::WinRM::WinRMWebService.new(endpoint, :plaintext, endpoint_options)
|
||||||
client.set_timeout(@timeout_in_seconds)
|
client.set_timeout(@timeout_in_seconds)
|
||||||
|
@ -131,7 +134,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def endpoint
|
def endpoint
|
||||||
"http://#{@host}:#{@port}/wsman"
|
"http#{@ssl ? 's' : ''}://#{@host}:#{@port}/wsman"
|
||||||
end
|
end
|
||||||
|
|
||||||
def endpoint_options
|
def endpoint_options
|
||||||
|
@ -140,7 +143,8 @@ module VagrantPlugins
|
||||||
host: @host,
|
host: @host,
|
||||||
port: @port,
|
port: @port,
|
||||||
operation_timeout: @timeout_in_seconds,
|
operation_timeout: @timeout_in_seconds,
|
||||||
basic_auth_only: true }
|
basic_auth_only: true,
|
||||||
|
no_ssl_peer_verification: true }
|
||||||
end
|
end
|
||||||
end #WinShell class
|
end #WinShell class
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,7 +28,8 @@ Gem::Specification.new do |s|
|
||||||
s.add_dependency "rb-kqueue", "~> 0.2.0"
|
s.add_dependency "rb-kqueue", "~> 0.2.0"
|
||||||
s.add_dependency "rest-client", ">= 1.6.0", "< 2.0"
|
s.add_dependency "rest-client", ">= 1.6.0", "< 2.0"
|
||||||
s.add_dependency "wdm", "~> 0.1.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.
|
# We lock this down to avoid compilation issues.
|
||||||
s.add_dependency "nokogiri", "= 1.6.3.1"
|
s.add_dependency "nokogiri", "= 1.6.3.1"
|
||||||
|
|
Loading…
Reference in New Issue