Sha256: fe5878697798dff90e2ec67c4f0fb7fb1d434eafd7ca49f001fcc3cf944d5188
Contents?: true
Size: 1.29 KB
Versions: 9
Compression:
Stored size: 1.29 KB
Contents
module OpsPreflight module OpsWorks require 'ops_preflight/ops_works/base' class Deploy < Base attr_accessor :app_name def initialize(stack_name, app_name) super stack_name @app_name = app_name end def call(release_num = nil) instances = instance_ids puts "Triggering deploy of v#{release_num} to #{instances.size} instance#{'s' if instances.size != 1}" resp = opsworks.client.create_deployment({ :stack_id => stack_id, :app_id => app_id, :instance_ids => instances, :command => { :name => 'deploy' }, :comment => release_num.nil? ? 'Preflight Deployment' : "Preflight Release v#{release_num}" }) end protected def app_id @app_id ||= begin resp = opsworks.client.describe_apps(:stack_id => stack_id) app = resp[:apps].find {|app| app[:name] == app_name} raise "OpsWorks app not found!" if app.nil? app[:app_id] end end def instance_ids resp = opsworks.client.describe_instances(:stack_id => stack_id) ids = [] resp[:instances].each {|instance| ids << instance[:instance_id] if instance[:status] == 'online' } ids end end end end
Version data entries
9 entries across 9 versions & 1 rubygems