foreplay 0.0.5 → 0.0.6
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.
- data/features/setup.feature +1 -0
- data/lib/foreplay/cli.rb +1 -0
- data/lib/foreplay/deploy.rb +44 -26
- data/lib/foreplay/setup.rb +1 -0
- data/lib/foreplay/setup/foreplay.yml +4 -2
- data/lib/foreplay/version.rb +1 -1
- data/spec/lib/foreplay/deploy_spec.rb +7 -0
- metadata +4 -4
data/features/setup.feature
CHANGED
@@ -14,6 +14,7 @@ Feature: Setup
|
|
14
14
|
name: aruba
|
15
15
|
repository: TODO Put the git repository path here
|
16
16
|
user: TODO Put here the user to logon to the deployment server
|
17
|
+
password: TODO Supply a password or private key to connect to the server
|
17
18
|
path: TODO Put here the path to deploy to on the deployment server
|
18
19
|
port: 50000
|
19
20
|
production:
|
data/lib/foreplay/cli.rb
CHANGED
data/lib/foreplay/deploy.rb
CHANGED
@@ -152,6 +152,12 @@ module Foreplay
|
|
152
152
|
:before => ' ',
|
153
153
|
:header => "#{environment}:",
|
154
154
|
:path => 'config/' },
|
155
|
+
{ :key => :resque,
|
156
|
+
:delimiter => ': ',
|
157
|
+
:suffix => '.yml',
|
158
|
+
:commentary => 'Building config/resque.yml',
|
159
|
+
:before => environment,
|
160
|
+
:path => 'config/' },
|
155
161
|
{ :command => 'bundle install --deployment --without development test',
|
156
162
|
:commentary => 'Using bundler to install the required gems in deployment mode' },
|
157
163
|
{ :command => 'sudo ln -f `which foreman` /usr/bin/foreman || echo Using default version of foreman',
|
@@ -230,8 +236,7 @@ module Foreplay
|
|
230
236
|
# Output from this step
|
231
237
|
output = ''
|
232
238
|
previous = '' # We don't need or want the final CRLF
|
233
|
-
|
234
|
-
commands = build_commands step, instructions
|
239
|
+
commands = build_step step, instructions
|
235
240
|
|
236
241
|
commands.each do |command|
|
237
242
|
process = sh.execute command
|
@@ -258,7 +263,7 @@ module Foreplay
|
|
258
263
|
else
|
259
264
|
# Deployment check: just say what we would have done
|
260
265
|
steps.each do |step|
|
261
|
-
commands =
|
266
|
+
commands = build_step step, instructions
|
262
267
|
|
263
268
|
commands.each { |command| puts "#{INDENT * 2}#{command}" unless step[:silent] }
|
264
269
|
end
|
@@ -267,41 +272,54 @@ module Foreplay
|
|
267
272
|
output
|
268
273
|
end
|
269
274
|
|
270
|
-
def
|
275
|
+
def build_step step, instructions
|
271
276
|
puts "#{INDENT}#{(step[:commentary] || step[:command]).yellow}" unless step[:silent] == true
|
272
277
|
|
273
278
|
# Each step can be (1) a command or (2) a series of values to add to a file
|
274
|
-
if step.has_key?
|
275
|
-
|
276
|
-
|
277
|
-
prefix = step[:prefix] || ''
|
278
|
-
suffix = step[:suffix] || ''
|
279
|
-
path = step[:path] || ''
|
280
|
-
before = step[:before] || ''
|
281
|
-
delimiter = step[:delimiter] || ''
|
282
|
-
after = step[:after] || ''
|
283
|
-
|
284
|
-
step[:silent] = true
|
285
|
-
filename = '%s%s%s%s' % [path, prefix, key, suffix]
|
286
|
-
|
287
|
-
if step.has_key?(:header)
|
288
|
-
commands = ['echo "%s" > %s' % [step[:header], filename]]
|
289
|
-
redirect = '>>'
|
279
|
+
if step.has_key?(:key)
|
280
|
+
if instructions.has_key?(step[:key])
|
281
|
+
build_commands step, instructions
|
290
282
|
else
|
291
|
-
|
292
|
-
redirect = '>'
|
283
|
+
[]
|
293
284
|
end
|
285
|
+
else
|
286
|
+
# ...or just execute the command specified
|
287
|
+
[step[:command]]
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
def build_commands step, instructions
|
292
|
+
# Add values from the config file to a file on the remote machine
|
293
|
+
key = step[:key]
|
294
|
+
prefix = step[:prefix] || ''
|
295
|
+
suffix = step[:suffix] || ''
|
296
|
+
path = step[:path] || ''
|
297
|
+
before = step[:before] || ''
|
298
|
+
delimiter = step[:delimiter] || ''
|
299
|
+
after = step[:after] || ''
|
300
|
+
|
301
|
+
step[:silent] = true
|
302
|
+
filename = '%s%s%s%s' % [path, prefix, key, suffix]
|
303
|
+
|
304
|
+
if step.has_key?(:header)
|
305
|
+
commands = ['echo "%s" > %s' % [step[:header], filename]]
|
306
|
+
redirect = '>>'
|
307
|
+
else
|
308
|
+
commands = []
|
309
|
+
redirect = '>'
|
310
|
+
end
|
294
311
|
|
312
|
+
if instructions[key].kind_of?(Hash)
|
295
313
|
instructions[key].each do |k, v|
|
296
314
|
commands << 'echo "%s%s%s%s%s" %s %s' % [before, k, delimiter, v, after, redirect, filename]
|
297
315
|
redirect = '>>'
|
298
316
|
end
|
299
|
-
|
300
|
-
commands
|
301
317
|
else
|
302
|
-
|
303
|
-
|
318
|
+
commands << 'echo "%s%s%s%s" %s %s' % [before, delimiter, instructions[key], after, redirect, filename]
|
319
|
+
redirect = '>>'
|
304
320
|
end
|
321
|
+
|
322
|
+
commands
|
305
323
|
end
|
306
324
|
|
307
325
|
def explanatory_text(hsh, key)
|
data/lib/foreplay/setup.rb
CHANGED
@@ -64,15 +64,17 @@
|
|
64
64
|
# key: value Values will go into the .env file as key=value
|
65
65
|
# foreman: Role level Contents of the .foreman file
|
66
66
|
# key: value
|
67
|
+
# resque: Role level Contents of the resque.yml file for configuring a central redis
|
68
|
+
# server for an environment, e.g. production: redis://mydom.com:6379
|
67
69
|
#
|
68
70
|
defaults:
|
69
71
|
name: <%= @options.name? ? @options.name : 'TODO Put the app name here' %>
|
70
72
|
repository: <%= @options.repository? ? @options.repository : 'TODO Put the git repository path here' %>
|
71
|
-
user: <%= @options.user? ? @options.user : 'TODO Put here the user to logon to the deployment server' %><%= @options.password? ? "\n password: #{@options.password}" : '' %><%= @options.keyfile? ? "\n keyfile: #{@options.keyfile}" : '' %><%= @options.private_key? ? "\n private_key: #{@options.private_key}" : '' %>
|
73
|
+
user: <%= @options.user? ? @options.user : 'TODO Put here the user to logon to the deployment server' %><%= @options.password? ? "\n password: #{@options.password}" : '' %><%= @options.keyfile? ? "\n keyfile: #{@options.keyfile}" : '' %><%= @options.private_key? ? "\n private_key: #{@options.private_key}" : '' %><%= !@options.password? && !@options.private_key? && !@options.keyfile? ? "\n password: TODO Supply a password or private key to connect to the server" : '' %>
|
72
74
|
path: <%= @options.path? ? @options.path : 'TODO Put here the path to deploy to on the deployment server' %>
|
73
75
|
port: <%= @options.port %>
|
74
76
|
production:
|
75
|
-
defaults:
|
77
|
+
defaults:<%= @options.resque_redis? ? "\n resque: #{@options.resque_redis}" : '' %>
|
76
78
|
database:
|
77
79
|
adapter: <%= @options.db_adapter %>
|
78
80
|
encoding: <%= @options.db_encoding %>
|
data/lib/foreplay/version.rb
CHANGED
@@ -70,6 +70,7 @@ describe Foreplay::Deploy do
|
|
70
70
|
'rvm rvmrc warning ignore 50000',
|
71
71
|
'cd 50000',
|
72
72
|
'if [ -f .ruby-version ] ; then rvm install `cat .ruby-version` ; else echo "No .ruby-version file found" ; fi',
|
73
|
+
'mkdir -p config',
|
73
74
|
'echo "RAILS_ENV=production" > .env',
|
74
75
|
'echo "concurrency: web=1,worker=0,scheduler=0" > .foreman',
|
75
76
|
'echo "app: foreplay-50000" >> .foreman',
|
@@ -112,4 +113,10 @@ describe Foreplay::Deploy do
|
|
112
113
|
`foreplay setup -r git@github.com:Xenapto/foreplay.git -s web.example.com -f apps/%a -u fred -k "top secret private key"`
|
113
114
|
Foreplay::Deploy.start([:deploy, 'production', ''])
|
114
115
|
end
|
116
|
+
|
117
|
+
it "should add Redis details for Resque" do
|
118
|
+
`rm -f config/foreplay.yml`
|
119
|
+
`foreplay setup -r git@github.com:Xenapto/foreplay.git -s web.example.com -f apps/%a -u fred --resque-redis "redis://localhost:6379"`
|
120
|
+
Foreplay::Deploy.start([:deploy, 'production', ''])
|
121
|
+
end
|
115
122
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreplay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.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: 2013-
|
12
|
+
date: 2013-12-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -250,7 +250,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
250
250
|
version: '0'
|
251
251
|
segments:
|
252
252
|
- 0
|
253
|
-
hash:
|
253
|
+
hash: -463785199640223195
|
254
254
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
255
255
|
none: false
|
256
256
|
requirements:
|
@@ -259,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
259
|
version: '0'
|
260
260
|
segments:
|
261
261
|
- 0
|
262
|
-
hash:
|
262
|
+
hash: -463785199640223195
|
263
263
|
requirements: []
|
264
264
|
rubyforge_project:
|
265
265
|
rubygems_version: 1.8.25
|