lib/koma/backend/ssh.rb in koma-0.10.1 vs lib/koma/backend/ssh.rb in koma-0.11.0
- old
+ new
@@ -18,39 +18,41 @@
result = gather_via_ssh(host, options)
end
result
end
- def run_command(command)
+ def run_commands(commands)
if host.include?(',')
list = host.split(',').uniq
results = Parallel.map(list) do |h|
- run_command_via_ssh(h, options, command)
+ run_commands_via_ssh(h, options, commands)
end
arr = [list, results].transpose
result = Hash[*arr.flatten]
else
- result = run_command_via_ssh(host, options, command)
+ result = run_commands_via_ssh(host, options, commands)
end
result
end
def gather_via_ssh(host, options)
set :ssh_options, build_ssh_options(host, options)
out(options[:key])
end
- def run_command_via_ssh(host, options, command)
+ def run_commands_via_ssh(host, options, commands)
set :ssh_options, build_ssh_options(host, options)
- result = Specinfra.backend.run_command(command)
- { command =>
- {
+ results = {}
+ commands.each do |command|
+ result = Specinfra.backend.run_command(command)
+ results[command] = {
exit_signal: result.exit_signal,
exit_status: result.exit_status,
stderr: result.stderr,
stdout: result.stdout
}
- }
+ end
+ results
end
private
def build_ssh_options(host, options)