Sha256: 9d37e5e4f24123efdc54c26d7019e873428a2189cb7f01c1ed932979d66fc327

Contents?: true

Size: 813 Bytes

Versions: 17

Compression:

Stored size: 813 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"] || host_vars["ansible_user"]
    host = host_vars["ansible_ssh_host"] || host_vars["ansible_host"]
    port = host_vars["ansible_ssh_port"] || host_vars["ansible_port"] || 22
    cmd = "ssh #{user}@#{host} -p #{port}"
    say cmd
    exec cmd
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
subspace-1.0.7 lib/subspace/commands/ssh.rb
subspace-1.0.6 lib/subspace/commands/ssh.rb
subspace-1.0.5 lib/subspace/commands/ssh.rb
subspace-1.0.4 lib/subspace/commands/ssh.rb
subspace-1.0.3 lib/subspace/commands/ssh.rb
subspace-1.0.2 lib/subspace/commands/ssh.rb
subspace-1.0.1 lib/subspace/commands/ssh.rb
subspace-1.0.0 lib/subspace/commands/ssh.rb
subspace-0.6.17 lib/subspace/commands/ssh.rb
subspace-0.6.16 lib/subspace/commands/ssh.rb
subspace-0.6.15 lib/subspace/commands/ssh.rb
subspace-0.5.15 lib/subspace/commands/ssh.rb
subspace-0.5.14 lib/subspace/commands/ssh.rb
subspace-0.4.14 lib/subspace/commands/ssh.rb
subspace-0.4.13 lib/subspace/commands/ssh.rb
subspace-0.4.11 lib/subspace/commands/ssh.rb
subspace-0.4.10 lib/subspace/commands/ssh.rb