Class: Admiral::Tasks::OpsWorks

Inherits:
Thor
  • Object
show all
Extended by:
Base
Includes:
Util::OpsWorks, Util::CloudFormation
Defined in:
lib/admiral-opsworks/tasks.rb

Constant Summary collapse

NAME =
'ow'
USAGE =
'ow <command> <options>'
DESCRIPTION =
'Commands for wielding AWS OpsWorks stacks.'

Instance Method Summary collapse

Methods included from Util::OpsWorks

#all_availability_zones, #attach_ebs_volumes, #create_instance, #detach_ebs_volumes, #get_all_instances, #instance_online?, #instance_status, #opsworks, #ssh_to_instance, #update_instances, #wait_for_instance

Instance Method Details

#deploy(app_name) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/admiral-opsworks/tasks.rb', line 53

def deploy(app_name)
  puts "[admiral] Deploying to opsworks"
  stack = client.stacks[stack_name(options[:environment])]
  stack_id = cf_query_output stack, 'StackId'
  app_id = cf_query_output stack, app_name

  raise "#{app_name} did not match any existing applications." unless app_id

  puts "[admiral] Deploying app #{app_id}."

  opsworks.create_deployment(
    stack_id: stack_id,
    app_id: app_id,
    command: {
      name: "deploy",
    }
  )
end

#provisionObject



26
27
28
29
30
31
32
# File 'lib/admiral-opsworks/tasks.rb', line 26

def provision
  stack = client.stacks[stack_name(options[:environment])]
  stack_id = cf_query_output(stack, "StackId")
  layer_id = cf_query_output(stack, "LayerId")

  update_instances stack_id, layer_id, options[:count]
end

#sshObject



42
43
44
45
46
47
48
49
# File 'lib/admiral-opsworks/tasks.rb', line 42

def ssh
  stack = client.stacks[stack_name(options[:environment])]
  stack_id = cf_query_output(stack, "StackId")
  layer_id = cf_query_output(stack, "LayerId")

  instances = get_all_instances(layer_id)
  ssh_to_instance instances[0], params(options[:environment])['SshKeyName'], options[:username]
end