Merge pull request #9 from chef/winrm

Winrm
This commit is contained in:
Dominik Richter 2015-09-10 13:34:49 +02:00
commit 66ded343b8
2 changed files with 12 additions and 8 deletions

View file

@ -53,7 +53,7 @@ class VulcanoCLI < Thor
desc: 'Specify a remote host which is tested.'
option :port, type: :numeric,
desc: 'Specify the login port for a remote scan.'
option :user, type: :string, default: 'root',
option :user, type: :string, default: nil,
desc: 'The login user for a remote scan.'
option :password, type: :string, default: nil,
desc: 'Login password for a remote scan, if required.'

View file

@ -1,6 +1,7 @@
# encoding: utf-8
require 'shellwords'
require 'winrm'
module Vulcano::Backends
class SpecinfraHelper < Vulcano.backend(1)
@ -114,7 +115,7 @@ module Vulcano::Backends
user_known_hosts_file: '/dev/null',
global_known_hosts_file: '/dev/null',
number_of_password_prompts: 0,
user: @conf['user'],
user: @conf['user'] || 'root',
password: @conf['password'],
keys: [@conf['key_file']].compact,
}
@ -127,7 +128,6 @@ module Vulcano::Backends
host = conf['host'].to_s
port = conf['port']
fail 'You must configure a target host.' if host.empty?
fail 'Port must be > 0 (not #{port})' unless port > 0
# SSL configuration
if conf['winrm_ssl']
@ -147,20 +147,24 @@ module Vulcano::Backends
si.os = { family: 'windows' }
# validation
user = conf['user'].to_s
pass = conf['password'].to_s
fail 'You must configure a WinRM user for login.' if user.empty?
user = @conf['user'].to_s
pass = @conf['password'].to_s
if user.empty?
warn "We use default 'Administrator' as WinRM user for login."
user = 'Administrator'
end
fail 'You must configure a WinRM password.' if pass.empty?
# create the connection
endpoint = winrm_url(conf)
endpoint = winrm_url(@conf)
winrm = ::WinRM::WinRMWebService.new(
endpoint,
:ssl,
user: user,
pass: pass,
basic_auth_only: true,
no_ssl_peer_verification: conf['winrm_self_signed'],
no_ssl_peer_verification: @conf['winrm_self_signed'],
)
si.winrm = winrm
end