Sha256: 00573aade9efef0ec0f2cff6d6f273c772063e65d8415d654eff51f9162fd30a

Contents?: true

Size: 849 Bytes

Versions: 1

Compression:

Stored size: 849 Bytes

Contents

# 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 console
      exec "#{ssh_cmd} #{cmd} c'\""
    end

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

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

    def ssh_cmd
      "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) bin/rails "
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contexto-0.2.3 lib/contexto/ssh.rb