simple_deploy 0.7.8 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f50c33ab5fad70dd5d5938374d342831e08a31c5
4
- data.tar.gz: 5eb200ab3c1249b4e003be67b4d0b31c61f551f1
3
+ metadata.gz: 832792b12e68e17d1db4be736d39c9336e98bd99
4
+ data.tar.gz: 910b11938e36f43f7a6ced19dfd7a561ceee0d8a
5
5
  SHA512:
6
- metadata.gz: 4d9ef0c4bd2d97750f3ae7e84bfe68c292a9ef53e0a5b38d238aaec69e63309f6437d8b1cdf3b2c225c18c175e0b19b2c6260ed46f5aee0950410691365552a8
7
- data.tar.gz: b518e05faba332143bb56f7baa11582492f4b3e0722dd5aada78bf2bad11e6f612696b7aba2b89ba8704d5d7b2018647de76a7ee2c7c4aa17098f19a7c89eed6
6
+ metadata.gz: 13bf1dd9a2954146bdbe181b5b064a7fcf028786fbe2e8be79f3cf1397bca87e7e7cd84ab4319846d03a5ef4835bdc8080346dd13dd124159fc8d2fdba5811a2
7
+ data.tar.gz: 4716579fc9991b71496aac673f36dab70f082361e30220ca1d654c39da945f9a71abdb17c9b934d4912ce16d8cf0151cd6b7f78da8f9481f88819475b106e46d
data/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
- ## HEAD:
1
+ ## v0.8.0 (12/13/13):
2
+
3
+ * Added flag to specify external ips
2
4
 
3
5
  ## v0.7.8 (12/11/13):
4
6
 
@@ -30,10 +30,11 @@ export SIMPLE_DEPLOY_SSH_USER=fred
30
30
  export SIMPLE_DEPLOY_SSH_KEY=$HOME/.ssh/id_dsa
31
31
  simple_deploy deploy -n STACK_NAME -n STACK_NAME -e ENVIRONMENT
32
32
 
33
- Using Internal IP for SSH:
33
+ Using Internal / External IP for SSH:
34
34
 
35
- Simple deploy defaults to using the public IP when ssh'ng to stacks. This option instructs it
36
- to use the private IP, which is needed when ssh'ng from one stack to another.
35
+ simple_deploy defaults to using the public IP when ssh'ng to stacks in classic, or the private IP when in a VPC.
36
+
37
+ The internal or external flag forces simple_deploy to use the given IP address.
37
38
 
38
39
  simple_deploy deploy -n STACK_NAME -n STACK_NAME -e ENVIRONMENT -i
39
40
 
@@ -48,6 +49,7 @@ EOS
48
49
  opt :name, "Stack name(s) of stack to deploy", :type => :string,
49
50
  :multi => true
50
51
  opt :quiet, "Quiet, do not send notifications"
52
+ opt :external, "Use external IP for ssh commands"
51
53
  opt :internal, "Use internal IP for ssh commands"
52
54
  end
53
55
 
@@ -65,6 +67,7 @@ EOS
65
67
 
66
68
  stack = Stack.new :name => name,
67
69
  :environment => @opts[:environment],
70
+ :external => @opts[:external],
68
71
  :internal => @opts[:internal]
69
72
 
70
73
  proceed = true
@@ -15,12 +15,13 @@ Execute command on given stack(s).
15
15
 
16
16
  simple_deploy execute -n STACK_NAME -n STACK_NAME -e ENVIRONMENT -c "COMMAND"
17
17
 
18
- Using Internal IP for SSH:
18
+ Using Internal / External IP for SSH:
19
19
 
20
- Simple deploy defaults to using the public IP when ssh'ng to stacks. This option instructs it
21
- to use the private IP, which is needed when ssh'ng from one stack to another.
20
+ simple_deploy defaults to using the public IP when ssh'ng to stacks in classic, or the private IP when in a VPC.
22
21
 
23
- simple_deploy deploy -n STACK_NAME -n STACK_NAME -e ENVIRONMENT -i
22
+ The internal or external flag forces simple_deploy to use the given IP address.
23
+
24
+ simple_deploy execute -n STACK_NAME -n STACK_NAME -e ENVIRONMENT -i
24
25
 
25
26
  EOS
26
27
  opt :help, "Display Help"
@@ -28,6 +29,7 @@ EOS
28
29
  :multi => true
29
30
  opt :command, "Command to execute.", :type => :string
30
31
  opt :environment, "Set the target environment", :type => :string
32
+ opt :external, "Use external IP for ssh commands"
31
33
  opt :internal, "Use internal IP for ssh commands"
32
34
  opt :log_level, "Log level: debug, info, warn, error", :type => :string,
33
35
  :default => 'info'
@@ -48,6 +50,7 @@ EOS
48
50
 
49
51
  stack = Stack.new :name => name,
50
52
  :environment => @opts[:environment],
53
+ :external => @opts[:external],
51
54
  :internal => @opts[:internal]
52
55
 
53
56
  begin
@@ -15,11 +15,20 @@ List instances for stack.
15
15
 
16
16
  simple_deploy instances -n STACK_NAME -e ENVIRONMENT
17
17
 
18
+ Using Internal / External IPs
19
+
20
+ simple_deploy defaults to using the public IP when return the IP for stacks in classic, or the private IP when in a VPC.
21
+
22
+ The internal or external flag forces simple_deploy to use the given IP address.
23
+
24
+ simple_deploy instances -n STACK_NAME -n STACK_NAME -e ENVIRONMENT -i
25
+
18
26
  EOS
19
27
  opt :help, "Display Help"
20
28
  opt :environment, "Set the target environment", :type => :string
21
29
  opt :name, "Stack name to manage", :type => :string
22
- opt :internal, "Use internal IP for ssh commands"
30
+ opt :external, "Return external IP for instances."
31
+ opt :internal, "Return internal IP for instances."
23
32
  end
24
33
 
25
34
  valid_options? :provided => @opts,
@@ -30,6 +39,7 @@ EOS
30
39
 
31
40
  stack = Stack.new :name => @opts[:name],
32
41
  :environment => @opts[:environment],
42
+ :external => @opts[:external],
33
43
  :internal => @opts[:internal]
34
44
 
35
45
  exit 1 unless stack.exists?
@@ -21,6 +21,7 @@ module SimpleDeploy
21
21
  @logger = SimpleDeploy.logger
22
22
 
23
23
  @use_internal_ips = !!args[:internal]
24
+ @use_external_ips = !!args[:external]
24
25
  @entry = Entry.new :name => @name
25
26
  end
26
27
 
@@ -120,13 +121,9 @@ module SimpleDeploy
120
121
  end
121
122
 
122
123
  def instances
123
- stack_reader.instances.map do |instance|
124
+ stack_reader.instances.map do |instance|
124
125
  instance['instancesSet'].map do |info|
125
- if info['vpcId'] || @use_internal_ips
126
- info['privateIpAddress']
127
- else
128
- info['ipAddress']
129
- end
126
+ determine_ip_address(info)
130
127
  end
131
128
  end.flatten.compact
132
129
  end
@@ -210,6 +207,18 @@ module SimpleDeploy
210
207
  :ssh_key => ssh_key
211
208
  end
212
209
 
210
+ def determine_ip_address(info)
211
+ if info['vpcId']
212
+ address = @use_external_ips ? info['ipAddress'] : info['privateIpAddress']
213
+ unless address
214
+ @logger.warn "Instance '#{info['instanceId']}' does not have an external address, skipping."
215
+ end
216
+ address
217
+ else
218
+ @use_internal_ips ? info['privateIpAddress'] : info['ipAddress']
219
+ end
220
+ end
221
+
213
222
  def ssh_key
214
223
  ENV['SIMPLE_DEPLOY_SSH_KEY'] ||= "#{ENV['HOME']}/.ssh/id_rsa"
215
224
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleDeploy
2
- VERSION = "0.7.8"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -46,6 +46,7 @@ describe SimpleDeploy::CLI::Deploy do
46
46
  :log_level => 'debug',
47
47
  :name => ['my_stack'],
48
48
  :force => true,
49
+ :external => false,
49
50
  :internal => false,
50
51
  :attributes => [] }
51
52
 
@@ -75,6 +76,7 @@ describe SimpleDeploy::CLI::Deploy do
75
76
  :log_level => 'debug',
76
77
  :name => ['my_stack'],
77
78
  :force => true,
79
+ :external => false,
78
80
  :internal => false,
79
81
  :attributes => ['foo=bah'] }
80
82
 
@@ -102,6 +104,7 @@ describe SimpleDeploy::CLI::Deploy do
102
104
  :log_level => 'debug',
103
105
  :name => ['my_stack'],
104
106
  :force => true,
107
+ :external => false,
105
108
  :internal => false,
106
109
  :attributes => ['foo=bah'] }
107
110
 
@@ -131,6 +134,7 @@ describe SimpleDeploy::CLI::Deploy do
131
134
  :log_level => 'debug',
132
135
  :name => ['my_stack'],
133
136
  :force => true,
137
+ :external => false,
134
138
  :internal => false,
135
139
  :attributes => [] }
136
140
 
data/spec/stack_spec.rb CHANGED
@@ -201,11 +201,15 @@ describe SimpleDeploy::Stack do
201
201
 
202
202
  @instances = [
203
203
  { 'instancesSet' => [{ 'ipAddress' => '50.40.30.20',
204
- 'privateIpAddress' => '10.1.2.3' }] }
204
+ 'privateIpAddress' => '10.1.2.3' }]}
205
+ ]
206
+ @private_instances = [
207
+ { 'instancesSet' => [{ 'ipAddress' => nil,
208
+ 'privateIpAddress' => '10.3.2.1' }]}
205
209
  ]
206
210
  end
207
211
 
208
- it 'should use the private IP when vpc' do
212
+ it 'should use the private IP when vpc and not internal or external' do
209
213
  @instances.first['instancesSet'].first['vpcId'] = 'my-vpc'
210
214
 
211
215
  SimpleDeploy::StackReader.should_receive(:new).
@@ -216,6 +220,15 @@ describe SimpleDeploy::Stack do
216
220
  @stack.instances.should == ['10.1.2.3']
217
221
  end
218
222
 
223
+ it 'should use the public IP when not vpc and not internal or external' do
224
+ SimpleDeploy::StackReader.should_receive(:new).
225
+ with(:name => 'test-stack').
226
+ and_return @stack_reader_mock
227
+ @stack_reader_mock.should_receive(:instances).and_return(@instances)
228
+
229
+ @stack.instances.should == ['50.40.30.20']
230
+ end
231
+
219
232
  it 'should use the private IP when internal' do
220
233
  stack = SimpleDeploy::Stack.new :name => 'test-stack',
221
234
  :environment => 'test-env',
@@ -229,13 +242,32 @@ describe SimpleDeploy::Stack do
229
242
  stack.instances.should == ['10.1.2.3']
230
243
  end
231
244
 
232
- it 'should use the public IP when not vpc and not internal' do
245
+ it 'should use the public IP when external' do
246
+ @instances.first['instancesSet'].first['vpcId'] = 'my-vpc'
247
+ stack = SimpleDeploy::Stack.new :name => 'test-stack',
248
+ :environment => 'test-env',
249
+ :external => true
250
+
233
251
  SimpleDeploy::StackReader.should_receive(:new).
234
252
  with(:name => 'test-stack').
235
253
  and_return @stack_reader_mock
236
254
  @stack_reader_mock.should_receive(:instances).and_return(@instances)
237
255
 
238
- @stack.instances.should == ['50.40.30.20']
256
+ stack.instances.should == ['50.40.30.20']
257
+ end
258
+
259
+ it 'should not include the instance when external and no public IP' do
260
+ @instances.first['instancesSet'].first['vpcId'] = 'my-vpc'
261
+ stack = SimpleDeploy::Stack.new :name => 'test-stack',
262
+ :environment => 'test-env',
263
+ :external => true
264
+
265
+ SimpleDeploy::StackReader.should_receive(:new).
266
+ with(:name => 'test-stack').
267
+ and_return @stack_reader_mock
268
+ @stack_reader_mock.should_receive(:instances).and_return(@private_instances)
269
+
270
+ stack.instances.should == []
239
271
  end
240
272
 
241
273
  it 'should handle instanceSets with multiple intances' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Weaver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-11 00:00:00.000000000 Z
11
+ date: 2013-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fakefs