From 8fe3b8ad4de941cfede17714f79db9cffe52c7e1 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Fri, 25 Sep 2015 12:30:59 +0200 Subject: [PATCH 1/4] add ssh configuration options Signed-off-by: Dominik Richter --- lib/vulcano/backend/ssh.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/vulcano/backend/ssh.rb b/lib/vulcano/backend/ssh.rb index 9c8371873..c3e96dd69 100644 --- a/lib/vulcano/backend/ssh.rb +++ b/lib/vulcano/backend/ssh.rb @@ -84,6 +84,10 @@ module Vulcano::Backends user_known_hosts_file: '/dev/null', global_known_hosts_file: '/dev/null', number_of_password_prompts: 0, + keepalive: true, + keepalive_interval: 60, + compression: true, + compression_level: 6, password: @conf['password'] || ssh_config[:password], keys: keys, } From c3d226e4a2170b6153d1c30dd9adaf7828ff2483 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Fri, 25 Sep 2015 12:31:51 +0200 Subject: [PATCH 2/4] add os detection to ssh backend Signed-off-by: Dominik Richter --- lib/vulcano/backend/ssh.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/vulcano/backend/ssh.rb b/lib/vulcano/backend/ssh.rb index c3e96dd69..0f3e80bf0 100644 --- a/lib/vulcano/backend/ssh.rb +++ b/lib/vulcano/backend/ssh.rb @@ -4,12 +4,14 @@ module Vulcano::Backends class SSH < Vulcano.backend(1) name 'ssh' + attr_reader :os def initialize(conf) @conf = conf @files = {} @conf['host'] || fail('You must specify a SSH host.') @ssh = start_ssh + @os = OS.new(self) end def file(path) @@ -95,5 +97,12 @@ module Vulcano::Backends validate_options(options) Net::SSH.start(host, user, options) end + + class OS < OSCommon + def initialize(backend) + super(backend, { family: 'unix' }) + end + end + end end From 6d7a46a5898ffb4b31877d6d0c6c3e10dc2b8815 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Fri, 25 Sep 2015 13:25:57 +0200 Subject: [PATCH 3/4] bugfix: do not allocate pty on ssh by default PTY will effectively disable stderr output, so avoid it for now. It will come up very soon when we get back to sudo; see if fifo or other solutions might be used. Stderr is important for accurate command execution... For reference see this wonderful explanation: http://unix.stackexchange.com/a/134169 Signed-off-by: Dominik Richter --- lib/vulcano/backend/ssh.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/vulcano/backend/ssh.rb b/lib/vulcano/backend/ssh.rb index 0f3e80bf0..b4a1ea980 100644 --- a/lib/vulcano/backend/ssh.rb +++ b/lib/vulcano/backend/ssh.rb @@ -24,9 +24,6 @@ module Vulcano::Backends cmd.force_encoding('binary') if cmd.respond_to?(:force_encoding) @ssh.open_channel do |channel| - channel.request_pty do |_, success| - abort 'Could not obtain pty on SSH channel ' if !success - end channel.exec(cmd) do |_, success| unless success abort 'Couldn\'t execute command on SSH.' From 31a960e2b6e3111026f85eb60e14718b571c2cf0 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Fri, 25 Sep 2015 14:09:41 +0200 Subject: [PATCH 4/4] add ssh backend to runner kitchen tests Signed-off-by: Dominik Richter --- test/runner/test_ssh.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/runner/test_ssh.rb b/test/runner/test_ssh.rb index a0f721859..9c7b0a683 100644 --- a/test/runner/test_ssh.rb +++ b/test/runner/test_ssh.rb @@ -3,16 +3,21 @@ require_relative 'helper' require 'vulcano/backend' backends = {} +backend_conf = Vulcano::Backend.target_config({ + 'target' => 'ssh://vagrant@localhost', + 'key_file' => '/root/.ssh/id_rsa', +}) backends[:specinfra_ssh] = proc { - backend_conf = Vulcano::Backend.target_config({ - 'target' => 'ssh://vagrant@localhost', - 'key_file' => '/root/.ssh/id_rsa', - }) backend_class = Vulcano::Backend.registry['specinfra'] backend_class.new(backend_conf) } +backends[:ssh] = proc { + backend_class = Vulcano::Backend.registry['ssh'] + backend_class.new(backend_conf) +} + tests = ARGV backends.each do |type, get_backend|