Class: Contexto::SSH

Inherits:
Object
  • Object
show all
Defined in:
lib/contexto/ssh.rb

Overview

SSH class

Instance Method Summary collapse

Constructor Details

#initialize(ipaddress, cluster, service, container) ⇒ SSH

Returns a new instance of SSH.



5
6
7
8
9
10
11
12
13
14
# File 'lib/contexto/ssh.rb', line 5

def initialize(ipaddress, cluster, service, container)
  @ipaddress    = ipaddress
  @cluster      = cluster
  @service      = service
  @container    = container
  @bastion_host = 'bastion.empatico.xyz'
  @bastion_user = ''
  @user_name    = 'ec2-user'
  @options      = {}
end

Instance Method Details

#cmdObject



32
33
34
# File 'lib/contexto/ssh.rb', line 32

def cmd
  "'docker exec -it \\$(docker ps | grep ecs-#{@cluster}-#{@service}-.*-#{@container} | cut -d\\  -f1) bin/rails "
end

#consoleObject



16
17
18
# File 'lib/contexto/ssh.rb', line 16

def console
  exec "#{ssh_cmd} #{cmd} c'\""
end

#rake(rake_cmd) ⇒ Object



24
25
26
# File 'lib/contexto/ssh.rb', line 24

def rake(rake_cmd)
  exec "#{cmd} #{rake_cmd}'\""
end

#sshObject



20
21
22
# File 'lib/contexto/ssh.rb', line 20

def ssh
  exec "#{ssh_cmd}\""
end

#ssh_cmdObject



28
29
30
# File 'lib/contexto/ssh.rb', line 28

def ssh_cmd
  "ssh -t -A #{@bastion_host} \"ssh -t ec2-user@#{@ipaddress} "
end