stackit 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stackit/mixin/opsworks.rb +70 -1
- data/lib/stackit/stack/managed_stack_service.rb +0 -2
- data/lib/stackit/version.rb +1 -1
- data/lib/stackit/wait.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64a90ba15bf97b7a8212b76b81b84018fb5d406a
|
4
|
+
data.tar.gz: 32c5c71e84a560f59028d8ef96f13a1ed522dac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3672ea775e88199023a66c0b424f054291d896aec9e925fbb1c429b87b2121dbe3d6c410d2d61754571b66de46ffb39145614668baaac518897a4ec32607b0f2
|
7
|
+
data.tar.gz: dc882c7bd34b0d04000eab172152ff6a26fc8a24d86a06e0fa4916d1c47b6c1a8e68a16e02ac2393bbd177f5b751f7c8026eb41b4b57d4e2456744859816eccf
|
@@ -1,5 +1,9 @@
|
|
1
1
|
module Stackit::Mixin::OpsWorks
|
2
2
|
|
3
|
+
include Stackit::Wait
|
4
|
+
|
5
|
+
attr_accessor :opsworks
|
6
|
+
|
3
7
|
def opsworks_service_role_arn(key = :OpsWorksServiceRole)
|
4
8
|
"arn:aws:iam::#{Stackit.aws.account_id}:role/#{resolve_parameter(key)}"
|
5
9
|
end
|
@@ -8,5 +12,70 @@ module Stackit::Mixin::OpsWorks
|
|
8
12
|
"https://s3.amazonaws.com/#{resolve_parameter(key)}/#{cookbook_archive}"
|
9
13
|
end
|
10
14
|
|
11
|
-
|
15
|
+
def opsworks_stack_id(key = :OpsWorksStack)
|
16
|
+
Stackit::ParameterResolver.new(stack).resolve(key)
|
17
|
+
end
|
12
18
|
|
19
|
+
def opsworks_layer_id(key = :OpsWorksLayer)
|
20
|
+
Stackit::ParameterResolver.new(stack).resolve(key)
|
21
|
+
end
|
22
|
+
|
23
|
+
def opsworks_layers(stack_id)
|
24
|
+
opsworks.describe_layers(
|
25
|
+
stack_id: stack_id
|
26
|
+
).layers
|
27
|
+
end
|
28
|
+
|
29
|
+
def opsworks_instance(key = :OpsWorksInstance)
|
30
|
+
opsworks.describe_instances({
|
31
|
+
instance_ids: [
|
32
|
+
Stackit::ParameterResolver.new(stack).resolve(key)
|
33
|
+
]
|
34
|
+
})[:instances][0]
|
35
|
+
end
|
36
|
+
|
37
|
+
def opsworks_update_custom_cookbooks(stack_id, layer_id)
|
38
|
+
opsworks.create_deployment({
|
39
|
+
stack_id: stack_id,
|
40
|
+
layer_ids: [layer_id],
|
41
|
+
command: {
|
42
|
+
name: "update_custom_cookbooks"
|
43
|
+
}
|
44
|
+
})[:deployment_id]
|
45
|
+
end
|
46
|
+
|
47
|
+
def opsworks_execute_recipe(stack_id, layer_ids, recipes, attributes = nil)
|
48
|
+
recipes = recipes.is_a?(Array) ? recipes : [recipes]
|
49
|
+
layer_ids = layer_ids.is_a?(Array) ? layer_ids : [layer_ids]
|
50
|
+
opsworks.create_deployment({
|
51
|
+
stack_id: stack_id,
|
52
|
+
layer_ids: layer_ids,
|
53
|
+
command: {
|
54
|
+
name: "execute_recipes",
|
55
|
+
args: {
|
56
|
+
"recipes" => recipes,
|
57
|
+
},
|
58
|
+
},
|
59
|
+
custom_json: attributes
|
60
|
+
})[:deployment_id]
|
61
|
+
end
|
62
|
+
|
63
|
+
def opsworks_wait_for_deployment(deployment_id, status_pattern = /successful/)
|
64
|
+
Stackit.logger.info "Waiting for deployment #{deployment_id} to complete..."
|
65
|
+
wait_for(timeout: 15.minutes) do
|
66
|
+
deployment = Stackit.aws.opsworks.describe_deployments({
|
67
|
+
deployment_ids: [deployment_id]
|
68
|
+
})[:deployments][0]
|
69
|
+
case deployment.status
|
70
|
+
when /failed/
|
71
|
+
raise Stackit::WaitError, "Deployment failed during wait: #{deployment_id}"
|
72
|
+
when status_pattern
|
73
|
+
yield stack if block_given?
|
74
|
+
true
|
75
|
+
else
|
76
|
+
false
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
data/lib/stackit/version.rb
CHANGED
data/lib/stackit/wait.rb
CHANGED
@@ -4,7 +4,7 @@ module Stackit
|
|
4
4
|
|
5
5
|
module Wait
|
6
6
|
|
7
|
-
def
|
7
|
+
def wait_until_stack_has_key(key)
|
8
8
|
Stackit.logger.debug "Waiting until stack #{stack_name} has key #{key}..."
|
9
9
|
wait_for(timeout: 15.minutes) do
|
10
10
|
stack = Stack.new(stack_name: stack_name).hydrate!
|
@@ -51,7 +51,7 @@ module Stackit
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
|
54
|
+
protected
|
55
55
|
|
56
56
|
def wait_for(opts={})
|
57
57
|
raise ArgumentError, 'block expected' unless block_given?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Hahn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|