Sha256: fc3385163ca0548f164410fe33ff0f7e5f8565fda89310072497e57246c83641

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

require 'yaml'
require 'subspace/inventory'
class Subspace::Commands::Ssh < Subspace::Commands::Base
  PASS_THROUGH_PARAMS = ["i"]

  def initialize(args, options)
    @host = args.first
    @user = options.user
    @options = options
    run
  end

  def run
    if !inventory.hosts[@host]
      say "No host '#{@host}' found. "
      all_hosts = inventory.hosts.keys
      say (["Available hosts:"] + all_hosts).join("\n\t")
      return
    end
    host_vars = inventory.hosts[@host].vars
    user = host_vars["ansible_user"]
    host = host_vars["ansible_host"]
    port = host_vars["ansible_port"] || 22
    pem = host_vars["ansible_ssh_private_key_file"] || 'subspace.pem'
    cmd = "ssh #{user}@#{host} -p #{port} -i config/subspace/#{pem} #{pass_through_params.join(" ")}"
    say "> #{cmd} \n"
    exec cmd
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
subspace-3.0.0.rc1 lib/subspace/commands/ssh.rb