Class: OpsWorks::Stack

Inherits:
Resource show all
Defined in:
lib/opsworks/stack.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

account, client, #initialize

Constructor Details

This class inherits a constructor from OpsWorks::Resource

Instance Attribute Details

#id ⇒ Object

Returns the value of attribute id.



6
7
8
# File 'lib/opsworks/stack.rb', line 6

def id
  @id
end

#name ⇒ Object

Returns the value of attribute name.



6
7
8
# File 'lib/opsworks/stack.rb', line 6

def name
  @name
end

Class Method Details

.all ⇒ Object



8
9
10
11
12
# File 'lib/opsworks/stack.rb', line 8

def self.all
  client.describe_stacks.data[:stacks].map do |hash|
    new(id: hash[:stack_id], name: hash[:name])
  end
end

.find_by_name(name) ⇒ Object



14
15
16
# File 'lib/opsworks/stack.rb', line 14

def self.find_by_name(name)
  all.find { |stack| stack.name == name }
end

Instance Method Details

#apps ⇒ Object



18
19
20
21
# File 'lib/opsworks/stack.rb', line 18

def apps
  @apps ||= initialize_apps
  @apps || []
end

#deploy_app(app) ⇒ Object



40
41
42
43
# File 'lib/opsworks/stack.rb', line 40

def deploy_app(app)
  fail 'App not found' unless app && app.id
  create_deployment(app_id: app.id, command: { name: 'deploy' })
end

#execute_recipe(recipe) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/opsworks/stack.rb', line 31

def execute_recipe(recipe)
  create_deployment(
    command: {
      name: 'execute_recipes',
      args: { 'recipes' => [recipe] }
    }
  )
end

#find_app_by_name(name) ⇒ Object



23
24
25
# File 'lib/opsworks/stack.rb', line 23

def find_app_by_name(name)
  apps.find { |app| app.name == name }
end

#update_custom_cookbooks ⇒ Object



27
28
29
# File 'lib/opsworks/stack.rb', line 27

def update_custom_cookbooks
  create_deployment(command: { name: 'update_custom_cookbooks' })
end