# Context module Contexto # SSH class class SSH attr_reader :ipaddress, :cluster, :service, :container 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 def term 'env TERM=xterm' end def console exec "#{ssh_cmd} #{cmd} #{term} bin/rails c'\"" end def ssh exec "#{ssh_cmd}\"" end def rake(rake_cmd) exec "#{ssh_cmd} #{cmd} #{rake_cmd}'\"" end def bash exec "#{ssh_cmd} #{cmd} #{term} /bin/bash'\"" end def ssh_cmd "TERM=xterm ssh -t -A #{@bastion_host} \"ssh -t ec2-user@#{ipaddress} " end def cmd "'docker exec -it \\$(docker ps | grep ecs-#{cluster}-#{service}-.*-#{container} | cut -d\\ -f1) " end end end