Sha256: d22b9f8c49e60822536c8f2dd9f9e5f267227f7499c7f77a6ec9649e1ff1749a

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module Ona

  class Server

    attr_accessor :id, :role, :ip, :pass, :desc, :dna

    def load_block id, &block
      @id = id
      yield(self)
    end

    def setup_ssh
      "rake upload_ssh_key server=root@#{ip} pass=#{pass} key=#{local_key}"
    end

    def say_deployed
      "say #{desc} deployed"
    end

    def say_finished_setup
      "say #{desc} setup terminated"
    end

    def bootstrap
      "rake bootstrap server=root@#{ip}"
    end

    def deploy
      "rake cook server=root@#{ip} dna=#{dna} instance_role=#{role}"
    end

    def to_ssh
"osascript 2>/dev/null <<EOF
    tell application \"Terminal\"
        activate
        do script with command \"ssh root@#{ip}\"
    end tell
EOF"
    end

    def to_short_s
      "#{id}".ljust(5) + "#{desc}"
    end

    def to_s
      "
  #{id} - #{desc}

      Id           #{id}
      Ip           #{ip}
      Dna          #{dna}
      Role         #{role}
      Password     #{pass}

      ssh root@#{ip}
      "
    end

    def local_key
      File.join(ENV['HOME'], '.ssh/id_rsa.pub')
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ona-0.1.5 lib/ona_server.rb
ona-0.1.4 lib/ona_server.rb