Sha256: 0bd87bbd9ead667d49dc10a9dec72e2e765307403e6d0f405450ea7cb66e3709

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 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
      puts 'Setting up key for root'
      "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 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.22 lib/ona_server.rb
ona-0.1.21 lib/ona_server.rb