Module: Admiral::Shell

Defined in:
lib/admiral/shell.rb

Class Method Summary collapse

Class Method Details

.local(cmd, options = {}, live = false) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/admiral/shell.rb', line 8

def self.local(cmd, options={}, live = false)
  sh = Mixlib::ShellOut.new(cmd, options)

  if live
    sh.live_stdout = STDOUT
  end

  sh.run_command
  if sh.error?
    puts "Failed to run #{cmd}"
    puts sh.stderr
    return nil
  else
    return sh.stdout
  end
end

.remote(host, username, keyfile, cmd) ⇒ Object



25
26
27
# File 'lib/admiral/shell.rb', line 25

def self.remote (host, username, keyfile, cmd)
  Kernel.exec("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no #{username}@#{host} -i #{keyfile}")
end