Sha256: 0be8b96cfd97c2fffdcda1bcc6b2dfc01b7221d5d7406cb128a3b8162694473a

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 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 say_sure_to_setup
      "say 'Are you sure to setup #{desc}'"
    end

    def say_sure_to_deploy
      "say 'Are you sure to deploy #{desc}'"
    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 user
"osascript 2>/dev/null <<EOF
    tell application \"Terminal\"
        activate
        do script with command \"ssh #{user}@#{ip}\"
    end tell
EOF"
    end

    def to_http
      "open http://#{ip}"
    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}

      "
    end

    def rake
      [setup_ssh, bootstrap, deploy]
    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.24 lib/ona_server.rb
ona-0.1.23 lib/ona_server.rb