class Skipper::Runner

Attributes

cli[R]
options[R]
servers[R]

Public Class Methods

new(servers, options = {}, cli) click to toggle source
# File lib/skipper/runner.rb, line 7
def initialize(servers, options = {}, cli)
  @servers = servers
  @options = options
  @cli = cli

  SSHKit::Backend::Netssh.configure do |ssh|
    ssh.ssh_options = ssh_options
  end

  SSHKit.config.output_verbosity = Logger::DEBUG if options.output?
end

Public Instance Methods

run(command) click to toggle source
# File lib/skipper/runner.rb, line 19
def run(command)
  on servers.hosts, on_options do
    execute command
  end
end

Private Instance Methods

on_options() click to toggle source
# File lib/skipper/runner.rb, line 41
def on_options
  opts = { in: run_in }

  [:limit, :wait].each do |key|
    opts[key] = options[key].to_i if options.send("#{key}?")
  end

  opts
end
run_in() click to toggle source
# File lib/skipper/runner.rb, line 29
def run_in
  return options.run_in.to_sym if options.run_in?

  if options.limit?
    :groups
  elsif options.wait?
    :sequence
  else
    :parallel
  end
end
ssh_options() click to toggle source
# File lib/skipper/runner.rb, line 51
def ssh_options
  opts = {}
  opts[:keys]          = [options.identity_file] if options.identiy_file?
  opts[:user]          = options.user
  opts[:forward_agent] = options.foward_agent
  opts
end