Sha256: 246a3e72ba2430d4cf70d0fc247407844fe9aaf2289e2aab8a2294a3d4d6843c

Contents?: true

Size: 922 Bytes

Versions: 6

Compression:

Stored size: 922 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} 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} /bin/bash'\""
    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) "
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
contexto-0.4.2 lib/contexto/ssh.rb
contexto-0.4.1 lib/contexto/ssh.rb
contexto-0.4.0 lib/contexto/ssh.rb
contexto-0.3.1 lib/contexto/ssh.rb
contexto-0.3.0 lib/contexto/ssh.rb
contexto-0.2.4 lib/contexto/ssh.rb