require 'specinfra' require 'pp' a = Specinfra::Backend::Exec.new ssh_options = Net::SSH::Config.for(ENV['SSH_HOST'], [ENV['SSH_CONFIG']]) b = Specinfra::Backend::Ssh.new( :host => ssh_options[:host_name], :ssh_options => ssh_options, ) threads = [a, b].map do |backend| Thread.start(backend) do |backend| result = [] result << backend.run_command("uname -a") result << backend.command result << backend.command.get(:install_package, 'dstat') result end end threads.each(&:join) threads.each do |t| pp t.value end # example: # [#, # #"darwin", :release=>nil, :arch=>"x86_64"}>, # "/usr/local/bin/brew install 'dstat'"] # [#, # #"ubuntu", :release=>"14.04", :arch=>"x86_64"}>, # "DEBIAN_FRONTEND='noninteractive' apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' install dstat"]