Sha256: 6a74394a2002fec9789653818cf38bc56544500e439375832220aee6a87b8819

Contents?: true

Size: 1.44 KB

Versions: 200

Compression:

Stored size: 1.44 KB

Contents

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:
# [#<Specinfra::CommandResult:0x007fb3b1352e30
#   @exit_signal=nil,
#   @exit_status=0,
#   @stderr="",
#   @stdout=
#    "Darwin p411 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64\n">,
#  #<Specinfra::CommandFactory:0x007fb3b1153508
#   @os_info={:family=>"darwin", :release=>nil, :arch=>"x86_64"}>,
#  "/usr/local/bin/brew install  'dstat'"]
# [#<Specinfra::CommandResult:0x007fb3b0b9c2e0
#   @exit_signal=nil,
#   @exit_status=0,
#   @stderr="",
#   @stdout=
#    "Linux itamae-trusty 3.13.0-39-generic #66-Ubuntu SMP Tue Oct 28 13:30:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux\n">,
#  #<Specinfra::CommandFactory:0x007fb3b0d4d4b8
#   @os_info={:family=>"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"]

Version data entries

200 entries across 200 versions & 3 rubygems

Version Path
specinfra-2.76.2 examples/multiple_backends.rb
specinfra-2.76.1 examples/multiple_backends.rb
specinfra-2.76.0 examples/multiple_backends.rb
specinfra-2.75.1 examples/multiple_backends.rb
specinfra-rb19-2.44.7 examples/multiple_backends.rb
specinfra-2.75.0 examples/multiple_backends.rb
specinfra-2.74.0 examples/multiple_backends.rb
specinfra-2.73.4 examples/multiple_backends.rb
specinfra-2.73.3 examples/multiple_backends.rb
specinfra-2.73.2 examples/multiple_backends.rb
specinfra-2.73.1 examples/multiple_backends.rb
specinfra-2.73.0 examples/multiple_backends.rb
specinfra-2.72.1 examples/multiple_backends.rb
specinfra-2.72.0 examples/multiple_backends.rb
specinfra-2.71.3 examples/multiple_backends.rb
specinfra-2.71.2 examples/multiple_backends.rb
specinfra-2.71.1 examples/multiple_backends.rb
specinfra-2.71.0 examples/multiple_backends.rb
specinfra-2.70.2 examples/multiple_backends.rb
specinfra-2.70.1 examples/multiple_backends.rb