foreplay 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +5 -1
- data/lib/foreplay/deploy.rb +13 -10
- data/lib/foreplay/version.rb +1 -1
- data/spec/lib/foreplay/deploy_spec.rb +5 -1
- 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: 62fed4f278257118a74f5de5caa3c7dd40e3b387
|
4
|
+
data.tar.gz: d147a749c74122ae09916f049a5f55a2959546d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cdd91eeadc8bef6324281617806068871c3a188b803d7e72f340d6e3a16aefb26c639c5b63e4ae0162183bcb4e2c2547dc0d26626ae6a469a30868bb0459aa0
|
7
|
+
data.tar.gz: aa4ab625feac4dd5adfaf2d02319f55d2087da680aa63c7641b57c7b1293621e00a74e81603382803b771881cdbdabb088b98590c4e14cf6026663b19e8a5b7e
|
data/.hound.yml
CHANGED
@@ -33,4 +33,8 @@ CyclomaticComplexity:
|
|
33
33
|
ClassLength:
|
34
34
|
Description: 'Avoid classes longer than 100 lines of code.'
|
35
35
|
CountComments: false # count full line comments?
|
36
|
-
Max:
|
36
|
+
Max: 281
|
37
|
+
|
38
|
+
Output:
|
39
|
+
Description: 'Checks for calls to puts, print, etc.'
|
40
|
+
Enabled: false
|
data/lib/foreplay/deploy.rb
CHANGED
@@ -17,7 +17,7 @@ module Foreplay
|
|
17
17
|
argument :filters, type: :hash, required: false
|
18
18
|
|
19
19
|
DEFAULTS_KEY = 'defaults'
|
20
|
-
INDENT =
|
20
|
+
INDENT = "\t"
|
21
21
|
|
22
22
|
def parse
|
23
23
|
# Explain what we're going to do
|
@@ -83,6 +83,7 @@ module Foreplay
|
|
83
83
|
|
84
84
|
def deploy_role(instructions)
|
85
85
|
servers = instructions[:servers]
|
86
|
+
threads = []
|
86
87
|
preposition = mode == :deploy ? 'to' : 'for'
|
87
88
|
|
88
89
|
if servers.length > 1
|
@@ -91,7 +92,8 @@ module Foreplay
|
|
91
92
|
puts message
|
92
93
|
end
|
93
94
|
|
94
|
-
servers.each { |server| deploy_to_server server, instructions }
|
95
|
+
servers.each { |server| threads << Thread.new { deploy_to_server server, instructions } }
|
96
|
+
threads.each { |thread| thread.join }
|
95
97
|
end
|
96
98
|
|
97
99
|
def deploy_to_server(server, instructions)
|
@@ -121,9 +123,9 @@ module Foreplay
|
|
121
123
|
current_port_string = execute_on_server(steps, instructions).strip!
|
122
124
|
|
123
125
|
if current_port_string.blank?
|
124
|
-
puts "#{INDENT}No instance is currently deployed"
|
126
|
+
puts "#{name}#{INDENT}No instance is currently deployed"
|
125
127
|
else
|
126
|
-
"#{INDENT}Current instance is using port #{current_port_string}"
|
128
|
+
"#{name}#{INDENT}Current instance is using port #{current_port_string}"
|
127
129
|
end
|
128
130
|
|
129
131
|
current_port = current_port_string.to_i
|
@@ -230,6 +232,7 @@ module Foreplay
|
|
230
232
|
end
|
231
233
|
|
232
234
|
def execute_on_server(steps, instructions)
|
235
|
+
name = instructions[:name]
|
233
236
|
server_port = instructions[:server]
|
234
237
|
user = instructions[:user]
|
235
238
|
password = instructions[:password]
|
@@ -267,12 +270,12 @@ module Foreplay
|
|
267
270
|
output = ''
|
268
271
|
|
269
272
|
if mode == :deploy
|
270
|
-
puts "#{INDENT}Connecting to #{server} on port #{port}"
|
273
|
+
puts "#{name}#{INDENT}Connecting to #{server} on port #{port}"
|
271
274
|
|
272
275
|
# SSH connection
|
273
276
|
begin
|
274
277
|
Net::SSH.start(server, user, options) do |session|
|
275
|
-
puts "#{INDENT}Successfully connected to #{server} on port #{port}"
|
278
|
+
puts "#{name}#{INDENT}Successfully connected to #{server} on port #{port}"
|
276
279
|
|
277
280
|
session.shell do |sh|
|
278
281
|
steps.each do |step|
|
@@ -292,7 +295,7 @@ module Foreplay
|
|
292
295
|
sh.wait!
|
293
296
|
|
294
297
|
if step[:ignore_error] == true || process.exit_status == 0
|
295
|
-
print output.gsub!(/^/, INDENT * 2) unless step[:silent] == true || output.blank?
|
298
|
+
print output.gsub!(/^/, "#{name}#{INDENT * 2}") unless step[:silent] == true || output.blank?
|
296
299
|
else
|
297
300
|
terminate(output)
|
298
301
|
end
|
@@ -301,14 +304,14 @@ module Foreplay
|
|
301
304
|
end
|
302
305
|
end
|
303
306
|
rescue SocketError => e
|
304
|
-
terminate "There was a problem starting an ssh session on #{server_port}:\n#{e.message}"
|
307
|
+
terminate "#{name}#{INDENT}There was a problem starting an ssh session on #{server_port}:\n#{e.message}"
|
305
308
|
end
|
306
309
|
else
|
307
310
|
# Deployment check: just say what we would have done
|
308
311
|
steps.each do |step|
|
309
312
|
commands = build_step step, instructions
|
310
313
|
|
311
|
-
commands.each { |command| puts "#{INDENT * 2}#{command}" unless step[:silent] }
|
314
|
+
commands.each { |command| puts "#{name}#{INDENT * 2}#{command}" unless step[:silent] }
|
312
315
|
end
|
313
316
|
end
|
314
317
|
|
@@ -316,7 +319,7 @@ module Foreplay
|
|
316
319
|
end
|
317
320
|
|
318
321
|
def build_step(step, instructions)
|
319
|
-
puts "#{INDENT}#{(step[:commentary] || step[:command]).yellow}" unless step[:silent] == true
|
322
|
+
puts "#{instructions[:name]}#{INDENT}#{(step[:commentary] || step[:command]).yellow}" unless step[:silent] == true
|
320
323
|
|
321
324
|
# Each step can be (1) a command or (2) a series of values to add to a file
|
322
325
|
if step.key?(:key)
|
data/lib/foreplay/version.rb
CHANGED
@@ -86,7 +86,11 @@ describe Foreplay::Deploy do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
it 'should deploy to the environment' do
|
89
|
-
Net::SSH
|
89
|
+
Net::SSH
|
90
|
+
.should_receive(:start)
|
91
|
+
.with(/web[12].example.com/, 'fred', verbose: :warn, port: 22, password: 'trollope')
|
92
|
+
.exactly(4).times
|
93
|
+
.and_yield(session)
|
90
94
|
|
91
95
|
[
|
92
96
|
'mkdir -p apps/foreplay && cd apps/foreplay && rm -rf 50000 && git clone -b master git@github.com:Xenapto/foreplay.git 50000',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreplay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xenapto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|