Module: Stackit::Mixin::OpsWorks
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Wait
#wait_for_stack, #wait_for_stack_to_delete, #wait_until_stack_has_key
Instance Attribute Details
#opsworks ⇒ Object
Returns the value of attribute opsworks.
5
6
7
|
# File 'lib/stackit/mixin/opsworks.rb', line 5
def opsworks
@opsworks
end
|
Instance Method Details
#opsworks_cookbook_source(key = :DevOpsBucket, cookbook_archive = 'cookbooks.tar.gz') ⇒ Object
11
12
13
|
# File 'lib/stackit/mixin/opsworks.rb', line 11
def opsworks_cookbook_source(key = :DevOpsBucket, cookbook_archive = 'cookbooks.tar.gz')
"https://s3.amazonaws.com/#{resolve_parameter(key)}/#{cookbook_archive}"
end
|
#opsworks_execute_recipe(stack_id, layer_ids, recipes, attributes = nil) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/stackit/mixin/opsworks.rb', line 47
def opsworks_execute_recipe(stack_id, layer_ids, recipes, attributes = nil)
recipes = recipes.is_a?(Array) ? recipes : [recipes]
layer_ids = layer_ids.is_a?(Array) ? layer_ids : [layer_ids]
opsworks.create_deployment({
stack_id: stack_id,
layer_ids: layer_ids,
command: {
name: "execute_recipes",
args: {
"recipes" => recipes,
},
},
custom_json: attributes
})[:deployment_id]
end
|
#opsworks_instance(key = :OpsWorksInstance) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/stackit/mixin/opsworks.rb', line 29
def opsworks_instance(key = :OpsWorksInstance)
opsworks.describe_instances({
instance_ids: [
Stackit::ParameterResolver.new(stack).resolve(key)
]
})[:instances][0]
end
|
#opsworks_layer_id(key = :OpsWorksLayer) ⇒ Object
#opsworks_layers(stack_id) ⇒ Object
23
24
25
26
27
|
# File 'lib/stackit/mixin/opsworks.rb', line 23
def opsworks_layers(stack_id)
opsworks.describe_layers(
stack_id: stack_id
).layers
end
|
#opsworks_service_role_arn(key = :OpsWorksServiceRole) ⇒ Object
7
8
9
|
# File 'lib/stackit/mixin/opsworks.rb', line 7
def opsworks_service_role_arn(key = :OpsWorksServiceRole)
"arn:aws:iam::#{Stackit.aws.account_id}:role/#{resolve_parameter(key)}"
end
|
#opsworks_stack_id(key = :OpsWorksStack) ⇒ Object
#opsworks_update_custom_cookbooks(stack_id, layer_id) ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/stackit/mixin/opsworks.rb', line 37
def opsworks_update_custom_cookbooks(stack_id, layer_id)
opsworks.create_deployment({
stack_id: stack_id,
layer_ids: [layer_id],
command: {
name: "update_custom_cookbooks"
}
})[:deployment_id]
end
|
#opsworks_wait_for_deployment(deployment_id, status_pattern = /successful/) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/stackit/mixin/opsworks.rb', line 63
def opsworks_wait_for_deployment(deployment_id, status_pattern = /successful/)
Stackit.logger.info "Waiting for deployment #{deployment_id} to complete..."
wait_for(timeout: 15.minutes) do
deployment = Stackit.aws.opsworks.describe_deployments({
deployment_ids: [deployment_id]
})[:deployments][0]
case deployment.status
when /failed/
raise Stackit::WaitError, "Deployment failed during wait: #{deployment_id}"
when status_pattern
yield stack if block_given?
true
else
false
end
end
end
|