Sha256: e534798a3d9962deaee226665d6168cb33be4ec7b7f15da9ae036a11afda35bf

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 Bytes

Contents

require 'yaml'
class Subspace::Commands::Ssh < Subspace::Commands::Base
  def initialize(args, options)
    @host = args.first
    @user = options.user
    run
  end

  def run
    if !File.exists? "config/provision/host_vars/#{@host}"
      say "No host '#{@host}' found. "
      all_hosts = Dir["config/provision/host_vars/*"].collect {|f| File.basename(f) }
      say (["Available hosts:"] + all_hosts).join("\n\t")
      return
    end
    host_vars = YAML.load_file("config/provision/host_vars/#{@host}")
    user = @user || host_vars["ansible_ssh_user"]
    cmd = "ssh #{user}@#{host_vars["ansible_ssh_host"]}"
    say cmd
    exec cmd
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
subspace-0.4.6 lib/subspace/commands/ssh.rb
subspace-0.4.5 lib/subspace/commands/ssh.rb