Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue#5 fix ignored param 'aws_no_reboot_on_create_ami' #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/capistrano/asg/ami.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ module Capistrano
module Asg
# Extend AWS Resource class to include AMI methods
class AMI < AWSResource
attr_reader :region_config
include Taggable

def self.create(&_block)
ami = new
def self.create(region_config = {}, &_block)
ami = new(region_config)
ami.cleanup do
ami.save
ami.tag 'deployed-with' => 'cap-asg'
Expand All @@ -14,12 +15,16 @@ def self.create(&_block)
end
end

def initialize(region_config = {})
@region_config = region_config
end

def save
info "Creating EC2 AMI from EC2 Instance: #{base_ec2_instance.id}"
ec2_instance = ec2_resource.instance(base_ec2_instance.id)
@aws_counterpart = ec2_instance.create_image(
name: name,
no_reboot: fetch(:aws_no_reboot_on_create_ami, true)
no_reboot: region_config.fetch(:aws_no_reboot_on_create_ami, true)
)
end

Expand All @@ -35,7 +40,7 @@ def destroy(images = [])
private

def name
timestamp fetch(:aws_ami_name_prefix, "latest-#{environment}-AMI")
timestamp region_config.fetch(:aws_ami_name_prefix, "latest-#{environment}-AMI")
end

def trash
Expand Down
2 changes: 1 addition & 1 deletion lib/capistrano/asg/tasks/asg.rake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace :asg do
# Iterate over relevant ASGs
regions[region].each do |asg|
set :aws_autoscale_group, asg
Capistrano::Asg::AMI.create do |ami|
Capistrano::Asg::AMI.create(fetch(region.to_sym, {})) do |ami|
puts "Autoscaling: Created AMI: #{ami.aws_counterpart.id} from region #{region} in ASG #{asg}"
Capistrano::Asg::LaunchConfiguration.create(ami, fetch(region.to_sym, {})) do |lc|
puts "Autoscaling: Created Launch Configuration: #{lc.aws_counterpart.name} from region #{region} in ASG #{asg}"
Expand Down