Class: OpsworksRollingDeploy::Services::DeployService

Inherits:
Object
  • Object
show all
Includes:
Clients, ElbMethods, OutputMethods
Defined in:
lib/opsworks_rolling_deploy/services/deploy_service.rb

Constant Summary

Constants included from ElbMethods

ElbMethods::ELB_STATUS_INSERVICE, ElbMethods::ELB_STATUS_OUTOFSERVICE

Instance Method Summary collapse

Methods included from ElbMethods

#add_into_pools, #deregister_instances_from_load_balancer, #get_elb_status, #pools_of_instance, #register_instances_with_load_balancer, #remove_from_pools, #wait_status

Methods included from OutputMethods

#info, #warn

Methods included from Clients

#elb_client, #ops_client

Instance Method Details

#deploy(stack_name, layer_name, app_name, command, command_args, pretend = true, exclude_patterns = []) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/opsworks_rolling_deploy/services/deploy_service.rb', line 14

def deploy(stack_name, layer_name, app_name, command, command_args, pretend = true, exclude_patterns = [])
  @pretend = pretend
  stack = get_stack(stack_name) || fail("Stack not found #{stack_name}'")
  app   = get_app(stack, app_name) || fail("App not found #{app_name}'")
  layer = layer_name && get_layer(stack, layer_name) # || fail("Layer not found #{layer_name}'")

  instances = instances_to_deploy(stack, layer, app, exclude_patterns)
  instances.shuffle!
  instances.each_with_index do |instance, idx|
    pools = remove_from_pools(stack, app, instance)
    comment = [ (layer ? layer.name : 'Full'), "#{idx+1}/#{instances.size}" ].compact.join(' ')
    create_deployment(stack, app, instance, command, command_args, comment) 
    add_into_pools(stack, instance, pools)
  end
end