simple_deploy 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/lib/simple_deploy/cli/clone.rb +7 -2
- data/lib/simple_deploy/cli/deploy.rb +11 -8
- data/lib/simple_deploy/notifier.rb +2 -2
- data/lib/simple_deploy/stack.rb +11 -7
- data/lib/simple_deploy/version.rb +1 -1
- data/simple_deploy.gemspec +1 -1
- data/spec/cli/clone_spec.rb +21 -0
- data/spec/cli/deploy_spec.rb +69 -1
- data/spec/notifier_spec.rb +5 -2
- data/spec/stack_spec.rb +23 -7
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## v0.5.6
|
2
|
+
|
3
|
+
* Corrected the instances command so it returns all instances
|
4
|
+
* Updated the clone command so it can take a new template for the new stack
|
5
|
+
* Added region to the message notifications
|
6
|
+
* Fixed deployments so they don't try to deploy if the attributes fail to update
|
7
|
+
|
1
8
|
## v0.5.5
|
2
9
|
|
3
10
|
* Added backoff functionality to updates so they work better with the force option
|
@@ -20,6 +20,7 @@ EOS
|
|
20
20
|
opt :new_name, "Stack name for the new stack", :type => :string
|
21
21
|
opt :attributes, "= separated attribute and it's value", :type => :string,
|
22
22
|
:multi => true
|
23
|
+
opt :template, "Path to a new template file", :type => :string
|
23
24
|
end
|
24
25
|
|
25
26
|
CLI::Shared.valid_options? :provided => @opts,
|
@@ -31,8 +32,12 @@ EOS
|
|
31
32
|
cloned_attributes = filter_attributes source_stack.attributes
|
32
33
|
new_attributes = merge_attributes cloned_attributes, override_attributes
|
33
34
|
|
34
|
-
|
35
|
-
|
35
|
+
if @opts[:template]
|
36
|
+
template_file = @opts[:template]
|
37
|
+
else
|
38
|
+
template_file = Tempfile.new("#{@opts[:new_name]}_template.json").path
|
39
|
+
File::open(template_file, 'w') { |f| f.write source_stack.template.to_json }
|
40
|
+
end
|
36
41
|
|
37
42
|
new_stack.create :attributes => new_attributes,
|
38
43
|
:template => template_file
|
@@ -65,14 +65,17 @@ EOS
|
|
65
65
|
:logger => logger,
|
66
66
|
:internal => opts[:internal]
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
if
|
72
|
-
notifier.
|
73
|
-
|
74
|
-
|
75
|
-
|
68
|
+
proceed = true
|
69
|
+
proceed = stack.update :force => opts[:force], :attributes => new_attributes if new_attributes.any?
|
70
|
+
|
71
|
+
if proceed
|
72
|
+
notifier.send_deployment_start_message unless opts[:quiet]
|
73
|
+
if stack.deploy opts[:force]
|
74
|
+
notifier.send_deployment_complete_message unless opts[:quiet]
|
75
|
+
else
|
76
|
+
logger.error "Deployment to #{name} did not complete succesfully."
|
77
|
+
exit 1
|
78
|
+
end
|
76
79
|
end
|
77
80
|
|
78
81
|
end
|
@@ -11,12 +11,12 @@ module SimpleDeploy
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def send_deployment_start_message
|
14
|
-
message = "Deployment to #{@stack_name} started."
|
14
|
+
message = "Deployment to #{@stack_name} in #{@config.region @environment} started."
|
15
15
|
send message
|
16
16
|
end
|
17
17
|
|
18
18
|
def send_deployment_complete_message
|
19
|
-
message = "Deployment to #{@stack_name} complete."
|
19
|
+
message = "Deployment to #{@stack_name} in #{@config.region @environment} complete."
|
20
20
|
attributes = stack.attributes
|
21
21
|
|
22
22
|
if attributes['app_github_url']
|
data/lib/simple_deploy/stack.rb
CHANGED
@@ -35,6 +35,10 @@ module SimpleDeploy
|
|
35
35
|
attributes = stack_attribute_formater.updated_attributes args[:attributes]
|
36
36
|
stack.update :attributes => attributes
|
37
37
|
@logger.info "Update complete for #{@name}."
|
38
|
+
true
|
39
|
+
else
|
40
|
+
@logger.info "Not clear to update."
|
41
|
+
false
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
@@ -72,14 +76,14 @@ module SimpleDeploy
|
|
72
76
|
|
73
77
|
def instances
|
74
78
|
stack.instances.map do |instance|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
79
|
+
instance['instancesSet'].map do |info|
|
80
|
+
if info['vpcId'] || @use_internal_ips
|
81
|
+
info['privateIpAddress']
|
82
|
+
else
|
83
|
+
info['ipAddress']
|
84
|
+
end
|
81
85
|
end
|
82
|
-
end
|
86
|
+
end.flatten
|
83
87
|
end
|
84
88
|
|
85
89
|
def status
|
data/simple_deploy.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_development_dependency "rspec"
|
22
22
|
|
23
23
|
s.add_runtime_dependency "capistrano"
|
24
|
-
s.add_runtime_dependency "stackster", '= 0.3.
|
24
|
+
s.add_runtime_dependency "stackster", '= 0.3.1'
|
25
25
|
s.add_runtime_dependency "tinder"
|
26
26
|
s.add_runtime_dependency "trollop"
|
27
27
|
end
|
data/spec/cli/clone_spec.rb
CHANGED
@@ -136,6 +136,27 @@ describe SimpleDeploy::CLI::Clone do
|
|
136
136
|
|
137
137
|
subject.clone
|
138
138
|
end
|
139
|
+
|
140
|
+
it 'should create the new stack using a new template' do
|
141
|
+
@options[:template] = 'brand_new_template.json'
|
142
|
+
|
143
|
+
SimpleDeploy::CLI::Shared.should_receive(:valid_options?).
|
144
|
+
with(:provided => @options,
|
145
|
+
:required => [:environment, :source_name, :new_name])
|
146
|
+
Trollop.stub(:options).and_return(@options)
|
147
|
+
|
148
|
+
@new_stack.should_receive(:create) do |options|
|
149
|
+
options[:attributes].should == [{ 'AmiId' => 'ami-7b6a4e3e' },
|
150
|
+
{ 'AppEnv' => 'pod-2-cd-1' },
|
151
|
+
{ 'MaximumAppInstances' => 1 },
|
152
|
+
{ 'MinimumAppInstances' => 1 },
|
153
|
+
{ 'chef_repo_bucket_prefix' => 'updated-intu-lc' },
|
154
|
+
{ 'chef_repo_domain' => 'updated_community_chef_repo' }]
|
155
|
+
options[:template].should match /brand_new_template.json/
|
156
|
+
end
|
157
|
+
|
158
|
+
subject.clone
|
159
|
+
end
|
139
160
|
end
|
140
161
|
end
|
141
162
|
end
|
data/spec/cli/deploy_spec.rb
CHANGED
@@ -110,7 +110,75 @@ describe SimpleDeploy::CLI::Deploy do
|
|
110
110
|
:internal => false).
|
111
111
|
and_return(@stack)
|
112
112
|
|
113
|
-
@stack.should_receive(:update).with(hash_including(:force => true, :attributes => [{'foo' => 'bah'}]))
|
113
|
+
@stack.should_receive(:update).with(hash_including(:force => true, :attributes => [{'foo' => 'bah'}])).and_return(true)
|
114
|
+
@stack.should_receive(:deploy).with(true).and_return(true)
|
115
|
+
@notifier.should_receive(:send_deployment_start_message)
|
116
|
+
@notifier.should_receive(:send_deployment_complete_message)
|
117
|
+
|
118
|
+
subject.deploy
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should skip the deploy if the attributes update is not successful" do
|
122
|
+
options = { :environment => 'my_env',
|
123
|
+
:log_level => 'debug',
|
124
|
+
:name => ['my_stack'],
|
125
|
+
:force => true,
|
126
|
+
:internal => false,
|
127
|
+
:attributes => ['foo=bah'] }
|
128
|
+
|
129
|
+
SimpleDeploy::CLI::Shared.should_receive(:valid_options?).
|
130
|
+
with(:provided => options,
|
131
|
+
:required => [:environment, :name])
|
132
|
+
Trollop.stub(:options).and_return(options)
|
133
|
+
|
134
|
+
SimpleDeploy::Notifier.should_receive(:new).
|
135
|
+
with(:stack_name => 'my_stack',
|
136
|
+
:environment => 'my_env',
|
137
|
+
:logger => @logger).
|
138
|
+
and_return(@notifier)
|
139
|
+
|
140
|
+
SimpleDeploy::Stack.should_receive(:new).
|
141
|
+
with(:environment => 'my_env',
|
142
|
+
:logger => @logger,
|
143
|
+
:name => 'my_stack',
|
144
|
+
:internal => false).
|
145
|
+
and_return(@stack)
|
146
|
+
|
147
|
+
@stack.should_receive(:update).with(hash_including(:force => true, :attributes => [{'foo' => 'bah'}])).and_return(false)
|
148
|
+
@stack.should_not_receive(:deploy)
|
149
|
+
@notifier.should_not_receive(:send_deployment_start_message)
|
150
|
+
@notifier.should_not_receive(:send_deployment_complete_message)
|
151
|
+
|
152
|
+
subject.deploy
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should do the deploy if there are no attributes to update" do
|
156
|
+
options = { :environment => 'my_env',
|
157
|
+
:log_level => 'debug',
|
158
|
+
:name => ['my_stack'],
|
159
|
+
:force => true,
|
160
|
+
:internal => false,
|
161
|
+
:attributes => [] }
|
162
|
+
|
163
|
+
SimpleDeploy::CLI::Shared.should_receive(:valid_options?).
|
164
|
+
with(:provided => options,
|
165
|
+
:required => [:environment, :name])
|
166
|
+
Trollop.stub(:options).and_return(options)
|
167
|
+
|
168
|
+
SimpleDeploy::Notifier.should_receive(:new).
|
169
|
+
with(:stack_name => 'my_stack',
|
170
|
+
:environment => 'my_env',
|
171
|
+
:logger => @logger).
|
172
|
+
and_return(@notifier)
|
173
|
+
|
174
|
+
SimpleDeploy::Stack.should_receive(:new).
|
175
|
+
with(:environment => 'my_env',
|
176
|
+
:logger => @logger,
|
177
|
+
:name => 'my_stack',
|
178
|
+
:internal => false).
|
179
|
+
and_return(@stack)
|
180
|
+
|
181
|
+
@stack.should_not_receive(:update)
|
114
182
|
@stack.should_receive(:deploy).with(true).and_return(true)
|
115
183
|
@notifier.should_receive(:send_deployment_start_message)
|
116
184
|
@notifier.should_receive(:send_deployment_complete_message)
|
data/spec/notifier_spec.rb
CHANGED
@@ -23,8 +23,10 @@ describe SimpleDeploy do
|
|
23
23
|
it "should support a basic start message" do
|
24
24
|
campfire_mock = mock 'campfire mock'
|
25
25
|
|
26
|
+
@config_mock.should_receive(:region).with('test').and_return('us-west-1')
|
27
|
+
|
26
28
|
SimpleDeploy::Notifier::Campfire.should_receive(:new).and_return campfire_mock
|
27
|
-
campfire_mock.should_receive(:send).with "Deployment to stack_name started."
|
29
|
+
campfire_mock.should_receive(:send).with "Deployment to stack_name in us-west-1 started."
|
28
30
|
|
29
31
|
@notifier.send_deployment_start_message
|
30
32
|
end
|
@@ -36,6 +38,7 @@ describe SimpleDeploy do
|
|
36
38
|
@config_mock.should_receive(:environment).
|
37
39
|
with('test').
|
38
40
|
and_return environment_mock
|
41
|
+
@config_mock.should_receive(:region).with('test').and_return('us-west-1')
|
39
42
|
Stackster::Stack.should_receive(:new).
|
40
43
|
with(:environment => 'test',
|
41
44
|
:name => 'stack_name',
|
@@ -50,7 +53,7 @@ describe SimpleDeploy do
|
|
50
53
|
SimpleDeploy::Notifier::Campfire.should_receive(:new).
|
51
54
|
and_return campfire_mock
|
52
55
|
campfire_mock.should_receive(:send).
|
53
|
-
with "Deployment to stack_name complete. App: http://github.com/user/app/commit/appsha Chef: http://github.com/user/chef_repo/commit/chefsha"
|
56
|
+
with "Deployment to stack_name in us-west-1 complete. App: http://github.com/user/app/commit/appsha Chef: http://github.com/user/chef_repo/commit/chefsha"
|
54
57
|
@notifier.send_deployment_complete_message
|
55
58
|
end
|
56
59
|
|
data/spec/stack_spec.rb
CHANGED
@@ -80,7 +80,7 @@ describe SimpleDeploy do
|
|
80
80
|
and_return @stack_mock
|
81
81
|
@stack_mock.should_receive(:update).with :attributes => @expected_attributes
|
82
82
|
|
83
|
-
@stack.update
|
83
|
+
@stack.update(:attributes => [{ 'chef_repo' => 'test123' }]).should be_true
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should not update when the deployment is locked and force is not set" do
|
@@ -90,7 +90,7 @@ describe SimpleDeploy do
|
|
90
90
|
SimpleDeploy::StackAttributeFormater.should_not_receive(:new)
|
91
91
|
Stackster::Stack.should_not_receive(:new)
|
92
92
|
|
93
|
-
@stack.update
|
93
|
+
@stack.update(:attributes => { 'arg1' => 'val' }).should_not be_true
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should update when the deployment is locked and force is set true" do
|
@@ -106,7 +106,7 @@ describe SimpleDeploy do
|
|
106
106
|
and_return @stack_mock
|
107
107
|
@stack_mock.should_receive(:update).with :attributes => @expected_attributes
|
108
108
|
|
109
|
-
@stack.update
|
109
|
+
@stack.update(:force => true, :attributes => [{ 'chef_repo' => 'test123' }]).should be_true
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should not update when the deployment is locked and force is set false" do
|
@@ -116,7 +116,7 @@ describe SimpleDeploy do
|
|
116
116
|
SimpleDeploy::StackAttributeFormater.should_not_receive(:new)
|
117
117
|
Stackster::Stack.should_not_receive(:new)
|
118
118
|
|
119
|
-
@stack.update
|
119
|
+
@stack.update(:force => false, :attributes => { 'arg1' => 'val' }).should_not be_true
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
@@ -176,7 +176,7 @@ describe SimpleDeploy do
|
|
176
176
|
@instances.first['instancesSet'].first['vpcId'] = 'my-vpc'
|
177
177
|
@stack_mock.stub(:instances).and_return(@instances)
|
178
178
|
|
179
|
-
stack.
|
179
|
+
stack.instances.should == ['10.1.2.3']
|
180
180
|
end
|
181
181
|
|
182
182
|
it 'should use the private IP when internal' do
|
@@ -188,7 +188,7 @@ describe SimpleDeploy do
|
|
188
188
|
stack.stub(:stack) { @stack_mock }
|
189
189
|
@stack_mock.stub(:instances).and_return(@instances)
|
190
190
|
|
191
|
-
stack.
|
191
|
+
stack.instances.should == ['10.1.2.3']
|
192
192
|
end
|
193
193
|
|
194
194
|
it 'should use the public IP when not vpc and not internal' do
|
@@ -200,7 +200,23 @@ describe SimpleDeploy do
|
|
200
200
|
stack.stub(:stack) { @stack_mock }
|
201
201
|
@stack_mock.stub(:instances).and_return(@instances)
|
202
202
|
|
203
|
-
stack.
|
203
|
+
stack.instances.should == ['50.40.30.20']
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'should handle instanceSets with multiple intances' do
|
207
|
+
@instances = [{ 'instancesSet' => [
|
208
|
+
{ 'ipAddress' => '50.40.30.20', 'privateIpAddress' => '10.1.2.3' },
|
209
|
+
{ 'ipAddress' => '50.40.30.21', 'privateIpAddress' => '10.1.2.4' }] }]
|
210
|
+
|
211
|
+
stack = SimpleDeploy::Stack.new :environment => 'test-env',
|
212
|
+
:name => 'test-stack',
|
213
|
+
:logger => 'my-logger',
|
214
|
+
:config => @config_stub,
|
215
|
+
:internal => false
|
216
|
+
stack.stub(:stack) { @stack_mock }
|
217
|
+
@stack_mock.stub(:instances).and_return(@instances)
|
218
|
+
|
219
|
+
stack.instances.should == ['50.40.30.20', '50.40.30.21']
|
204
220
|
end
|
205
221
|
end
|
206
222
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - '='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.3.
|
53
|
+
version: 0.3.1
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.3.
|
61
|
+
version: 0.3.1
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: tinder
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|