Sha256: c2856ff47dddcfd3679fac425b5284ef4f8201683cb82b45e34d128794efd5c8

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

require 'ey_cloud_awareness'
require 'pp'

task :eyc_setup, :roles => :app_master do
  version = Gem.searcher.find('ey_cloud_awareness').version.to_s
  begin
    run "gem list ey_cloud_awareness --installed --version #{version}"
  rescue
    $stderr.puts "[EY CLOUD AWARENESS GEM] app_master doesn't have ey_cloud_awareness --version #{version} installed. You need to have the exact same version installed."
    raise $!
  end

  upload File.expand_path(File.join(File.dirname(__FILE__), 'ey_cloud_awareness.rake')), "#{deploy_to}/current/lib/tasks/ey_cloud_awareness.rake"
  
  output = capture("cd #{deploy_to}/current && rake --silent eyc:to_json RAILS_ENV=#{rails_env}").gsub(/\s+/, ' ')
  if /(\{.*\})/.match(output)
    begin
      set :eyc_proxy, EngineYardCloudInstance.from_hash(ActiveSupport::JSON.decode($1))
    rescue
      $stderr.puts "[EY CLOUD AWARENESS GEM] Couldn't parse JSON, so just dumping what we got"
      $stderr.puts $1
      raise $!
    end
  else
    $stderr.puts "[EY CLOUD AWARENESS GEM] Didn't get JSON we recognized back, just dumping what we got"
    $stderr.puts output
    raise
  end
  eyc_proxy.app.each { |i| role :app, i.dns_name }
  eyc_proxy.db.each { |i| role :db, i.dns_name }
end

namespace :eyc do
  %w{ app db utility all first }.each do |name|
    task name, :roles => :app_master do
      pp eyc_proxy.send(name).map(&:to_hash)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ey_cloud_awareness-0.1.6 lib/tasks/capistrano_tasks.rb
ey_cloud_awareness-0.1.5 lib/tasks/capistrano_tasks.rb
ey_cloud_awareness-0.1.4 lib/tasks/capistrano_tasks.rb
ey_cloud_awareness-0.1.2 lib/tasks/capistrano_tasks.rb