Sha256: 1c5f1325d269508f8690fa3f6eee1941e1fffe537a5e4ec532ad9f0b424c461d

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

require "fileutils"
require "json"

namespace :aws do

  task :provision do
    aws_config = JSON.parse(File.read("config/aws.json"))[stage] || {}
    AWS::Provision.new(stage, aws_config, application).build_env
  end

  task :write_config do
     server_config = AWS::Provision.new.describe_env
     File.open("config/servers.json", "w") do |io|
       io << JSON.pretty_generate(server_config)
     end
  end

  desc "Allows ssh to instance by name. cap ssh <NAME>"
  task :ssh do
    server = variables[:logger].instance_variable_get("@options")[:actions][2]
    instance = AWS::Provision.new(stage).find_server_by_name(server)
    unless instance.nil?
      port = ssh_options[:port] || 22
      command = "ssh -p #{port} ubuntu@#{instance.dns_name}"
      puts "Running `#{command}`"
      exec(command)
    else
      puts "Server #{server} not found"
    end
  end
  
  desc "create autoscale setup from config/autoscale.json"
  task :create_autoscale do
    autoscale_config = JSON.parse(File.read("config/autoscale.json"))[stage] || {}
    AWS::Autoscale.new(stage, autoscale_config, application).configure_autoscale
  end

  desc "update autoscale from config/autoscale.json after a deployment"
  task :update_autoscale do
    autoscale_config = JSON.parse(File.read("config/autoscale.json"))[stage] || {}
    AWS::Autoscale.new(stage, autoscale_config, application).update_autoscale
  end

  desc "create a test instance from an autoscale image after a deployment"
  task :test_autoscale do
    autoscale_config = JSON.parse(File.read("config/autoscale.json"))[stage] || {}
    AWS::Autoscale.new(stage, autoscale_config, application).launch_test_instances
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
conan-0.4.12 lib/conan/cloud/tasks.rb
conan-0.4.11 lib/conan/cloud/tasks.rb