Sha256: 6dd8a9259fc8a00c2af5f80c40f1cd6d853cbf8fcbe719db6df59916c36f0cbe

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

require 'deprec-core'
Capistrano::Configuration.instance(:must_exist).load do 
  namespace :deprec do
    namespace :ec2 do
      
      set :ec2_zone, 'us-west-1'
 
      desc "Set some EC2 specific variables"
      task :default do
        unset :gateway
        ssh_options[:paranoid] = false
        set :network_dns_nameservers, '172.16.0.23' # valid outside us-west-1?
        set(:network_dns_search_path) {"#{ec2_zone}.compute.internal"}
        set :ec2_instance_id, 
          capture("curl http://169.254.169.254/latest/meta-data/instance-id")
      end

      desc "Disable termination of EC2 instances"
      task :safe do
        while true
          instanceid = ec2_instance_id ||
            Capistrano::CLI.ui.ask("instanceid") do |q|
              q.default = 'exit'
            end
          break if instanceid == 'exit'
          # Disable termination of this instance. Safety lock!
          `ec2-modify-instance-attribute --disable-api-termination true #{instanceid}`
          # Don't destroy EBS volume when instance terminated
          # This is default for EBS backed volumes but we want to be explicit. 
          `ec2-modify-instance-attribute --instance-initiated-shutdown-behavior stop #{instanceid}`
          break if ec2_instance_id # don't keep asking for instance id's 
        end
      end
 
    end 
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
deprec-3.1.0.rc16 lib/deprec/recipes/ec2.rb
deprec-3.1.0.rc15 lib/deprec/recipes/ec2.rb
deprec-3.1.0.rc13 lib/deprec/recipes/ec2.rb
deprec-3.1.0.rc12 lib/deprec/recipes/ec2.rb
deprec-3.1.0.rc11 lib/deprec/recipes/ec2.rb