railshoster 0.6.3 → 0.6.8
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/CHANGELOG.textile +16 -0
- data/Gemfile.lock +4 -4
- data/bin/railshoster +6 -1
- data/lib/railshoster/init_command.rb +16 -3
- data/lib/railshoster/init_database_helpers.rb +2 -2
- data/lib/railshoster/init_ssh_helpers.rb +15 -8
- data/lib/railshoster/no_ssh_key_given_error.rb +5 -0
- data/lib/railshoster/utilities.rb +5 -0
- data/lib/railshoster/version.rb +1 -1
- data/lib/railshoster.rb +1 -0
- data/spec/lib/railshoster/utilities_spec.rb +5 -0
- data/templates/h/deploy.rb.erb +53 -7
- metadata +8 -20
data/CHANGELOG.textile
CHANGED
@@ -73,3 +73,19 @@ h3. 0.6.1
|
|
73
73
|
h3. 0.6.3
|
74
74
|
|
75
75
|
* Updated message when there's no compatible database gem in Gemfile.lock.
|
76
|
+
|
77
|
+
h3. 0.6.4
|
78
|
+
|
79
|
+
* Fixed bug that the database.yml will link to the right release
|
80
|
+
|
81
|
+
h3. 0.6.5
|
82
|
+
|
83
|
+
* Process the asset pipeline if it is supported by the rails version
|
84
|
+
|
85
|
+
h3. 0.6.6
|
86
|
+
|
87
|
+
* Detection whether the Gemfile and Femfile.lock exists
|
88
|
+
|
89
|
+
h3. 0.6.7
|
90
|
+
|
91
|
+
* Get an error if no ssh key or ssh-direcotry exists
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
railshoster (0.6.
|
4
|
+
railshoster (0.6.6)
|
5
5
|
bundler (>= 1.0.15)
|
6
6
|
capistrano
|
7
7
|
capistrano-ext
|
@@ -26,7 +26,7 @@ GEM
|
|
26
26
|
erubis (2.7.0)
|
27
27
|
fakefs (0.4.0)
|
28
28
|
git (1.2.5)
|
29
|
-
gli (1.
|
29
|
+
gli (1.5.1)
|
30
30
|
highline (1.6.11)
|
31
31
|
json (1.6.5)
|
32
32
|
metaclass (0.0.1)
|
@@ -39,7 +39,7 @@ GEM
|
|
39
39
|
net-ssh (2.3.0)
|
40
40
|
net-ssh-gateway (1.1.0)
|
41
41
|
net-ssh (>= 1.99.1)
|
42
|
-
os (0.9.
|
42
|
+
os (0.9.6)
|
43
43
|
rspec (2.8.0)
|
44
44
|
rspec-core (~> 2.8.0)
|
45
45
|
rspec-expectations (~> 2.8.0)
|
@@ -48,7 +48,7 @@ GEM
|
|
48
48
|
rspec-expectations (2.8.0)
|
49
49
|
diff-lcs (~> 1.1.2)
|
50
50
|
rspec-mocks (2.8.0)
|
51
|
-
sane (0.
|
51
|
+
sane (0.25.3)
|
52
52
|
os
|
53
53
|
|
54
54
|
PLATFORMS
|
data/bin/railshoster
CHANGED
@@ -36,6 +36,11 @@ command [:init] do |c|
|
|
36
36
|
project_git_dir_name = args[0] || cwd
|
37
37
|
|
38
38
|
if options[:a] then
|
39
|
+
|
40
|
+
while options[:a].include?('\\n')
|
41
|
+
options[:a] = options[:a].gsub('\\n', "\n")
|
42
|
+
end
|
43
|
+
|
39
44
|
Railshoster::InitCommand.run_by_application_token(project_git_dir_name, options[:a])
|
40
45
|
elsif options[:j] then
|
41
46
|
Railshoster::InitCommand.new(project_git_dir_name, options[:j]).start
|
@@ -139,4 +144,4 @@ def ask_for_project_dir(current_working_dir)
|
|
139
144
|
end
|
140
145
|
end
|
141
146
|
|
142
|
-
exit GLI.run(ARGV)
|
147
|
+
exit GLI.run(ARGV)
|
@@ -61,6 +61,7 @@ module Railshoster
|
|
61
61
|
protected
|
62
62
|
|
63
63
|
def process_application_hash
|
64
|
+
expand_app_hash
|
64
65
|
expand_app_hash_product_specifically
|
65
66
|
# e.g. mysql2
|
66
67
|
@app_hash["db_gem"] = get_db_gem.name
|
@@ -76,23 +77,35 @@ module Railshoster
|
|
76
77
|
create_remote_authorized_key_file_from_app_hash(@app_hash, selected_key)
|
77
78
|
|
78
79
|
@app_hash["remote_db_yml"] = "#{@app_hash["deploy_to"]}/shared/config/database.yml"
|
79
|
-
|
80
|
+
|
81
|
+
@app_hash["h"].each do |host|
|
82
|
+
update_database_yml_db_adapters_via_ssh(host)
|
83
|
+
end
|
80
84
|
|
81
85
|
deployrb_str = create_deployrb(@app_hash)
|
82
86
|
write_deploy_rb(deployrb_str)
|
83
87
|
capify_project
|
84
88
|
success_message
|
85
89
|
end
|
90
|
+
|
91
|
+
def expand_app_hash
|
92
|
+
|
93
|
+
# Turn "h" in to an array unless it's not already one.
|
94
|
+
@app_hash["h"] = [ @app_hash["h"] ] unless @app_hash["h"].is_a?(Array)
|
95
|
+
end
|
86
96
|
|
87
97
|
# Add values ot app_hash specific to the given product type.
|
88
|
-
def expand_app_hash_product_specifically
|
98
|
+
def expand_app_hash_product_specifically
|
89
99
|
case @app_hash["t"].to_sym
|
90
100
|
when :h
|
91
101
|
@app_hash["deploy_to"] = "/home/#{@app_hash['u']}/#{@app_hash['a']}"
|
92
102
|
@app_hash["app_url"] = "http://#{@app_hash['u']}-#{@app_hash['aid']}.#{@app_hash['h']}"
|
93
103
|
when :v
|
94
|
-
@app_hash["deploy_to"] = "/var/www/#{@app_hash['a']}"
|
104
|
+
@app_hash["deploy_to"] = "/var/www/#{@app_hash['a']}"
|
95
105
|
@app_hash["app_url"] = "http://#{@app_hash['a']}.#{@app_hash['h']}"
|
106
|
+
when :pc
|
107
|
+
@app_hash["deploy_to"] = "/var/www/#{@app_hash['a']}"
|
108
|
+
@app_hash["app_url"] = "http://#{@app_hash['au']}"
|
96
109
|
else
|
97
110
|
raise UnsupportedApplicationTypeError.new
|
98
111
|
end
|
@@ -10,7 +10,7 @@ module Railshoster
|
|
10
10
|
protected
|
11
11
|
|
12
12
|
# Receive and update a database.yml via SFTP.
|
13
|
-
def update_database_yml_db_adapters_via_ssh(host
|
13
|
+
def update_database_yml_db_adapters_via_ssh(host, ssh_username = @app_hash["u"], path_to_dbyml = @app_hash["remote_db_yml"])
|
14
14
|
dbyml = ""
|
15
15
|
Net::SFTP.start(host, ssh_username) do |sftp|
|
16
16
|
sftp.file.open(path_to_dbyml) do |file|
|
@@ -50,4 +50,4 @@ module Railshoster
|
|
50
50
|
dbyml
|
51
51
|
end
|
52
52
|
end
|
53
|
-
end
|
53
|
+
end
|
@@ -9,19 +9,26 @@ module Railshoster
|
|
9
9
|
if app_hash["t"].eql?("h") then
|
10
10
|
|
11
11
|
# For a hosting package the password is the deploy user's password
|
12
|
-
create_remote_authorized_key_file(app_hash["h"], app_hash["u"], app_hash["p"], key)
|
12
|
+
create_remote_authorized_key_file(app_hash["h"].first, app_hash["u"], app_hash["p"], key)
|
13
13
|
elsif app_hash["t"].eql?("v") then
|
14
14
|
|
15
15
|
# For a vps the given password it the root user's password -> Register key for root user
|
16
|
-
create_remote_authorized_key_file(app_hash["h"], "root", app_hash["p"], key)
|
16
|
+
create_remote_authorized_key_file(app_hash["h"].first, "root", app_hash["p"], key)
|
17
17
|
|
18
18
|
# Also register the public key to enable key access to the deploy user
|
19
|
-
create_remote_authorized_key_file(app_hash["h"], "root", app_hash["p"], key, "/home/#{app_hash['u']}/.ssh", app_hash['u'])
|
19
|
+
create_remote_authorized_key_file(app_hash["h"].first, "root", app_hash["p"], key, "/home/#{app_hash['u']}/.ssh", app_hash['u'])
|
20
|
+
elsif app_hash["t"].eql?("pc") then
|
21
|
+
|
22
|
+
# For a private cloud setup we act on several vps
|
23
|
+
# but in this case the app_hash stores the deploy user's password not the root password as for vps setups
|
24
|
+
app_hash["h"].each do |host|
|
25
|
+
create_remote_authorized_key_file(host, app_hash["u"], app_hash["p"], key)
|
26
|
+
end
|
20
27
|
else
|
21
28
|
raise("Initialization aborted. Invalid product type: #{app_hash['t']}.")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
25
32
|
# Creates a remote authorized keys file for the given public key
|
26
33
|
#
|
27
34
|
# === Parameters
|
@@ -37,7 +44,7 @@ module Railshoster
|
|
37
44
|
|
38
45
|
#TODO Smarter way to determine home directory
|
39
46
|
stats = sftp.stat!("/home/#{target_username}") if target_username
|
40
|
-
|
47
|
+
|
41
48
|
begin
|
42
49
|
sftp.mkdir!(remote_dot_ssh_path)
|
43
50
|
sftp.setstat(remote_dot_ssh_path, :uid => stats.uid, :gid => stats.gid) if target_username
|
@@ -50,4 +57,4 @@ module Railshoster
|
|
50
57
|
end
|
51
58
|
end
|
52
59
|
end
|
53
|
-
end
|
60
|
+
end
|
@@ -32,6 +32,11 @@ module Railshoster
|
|
32
32
|
|
33
33
|
def self.select_public_ssh_key(ssh_dir = File.join(get_user_home, ".ssh"), options = {:verbose => true})
|
34
34
|
keys = Railshoster::Utilities.find_public_ssh_keys(ssh_dir, options)
|
35
|
+
|
36
|
+
if keys.size == 0
|
37
|
+
raise NoSshKeyGivenError.new("No SSH key given. Use the ssh-keygen command to generate one.")
|
38
|
+
end
|
39
|
+
|
35
40
|
return keys.first if keys.size == 1
|
36
41
|
|
37
42
|
puts "\nThere are multiple public ssh keys. Please choose your deploy key:"
|
data/lib/railshoster/version.rb
CHANGED
data/lib/railshoster.rb
CHANGED
@@ -8,6 +8,7 @@ require File.join(File.dirname(__FILE__), 'railshoster/capify_project_failed_err
|
|
8
8
|
require File.join(File.dirname(__FILE__), 'railshoster/bad_application_json_hash_error')
|
9
9
|
require File.join(File.dirname(__FILE__), 'railshoster/bad_appliction_token_error')
|
10
10
|
require File.join(File.dirname(__FILE__), 'railshoster/invalid_public_ssh_key_error')
|
11
|
+
require File.join(File.dirname(__FILE__), 'railshoster/no_ssh_key_given_error')
|
11
12
|
require File.join(File.dirname(__FILE__), 'railshoster/init_command')
|
12
13
|
require File.join(File.dirname(__FILE__), 'railshoster/deploy_command')
|
13
14
|
require File.join(File.dirname(__FILE__), 'railshoster/app_url_command')
|
@@ -75,6 +75,11 @@ describe Railshoster::Utilities do
|
|
75
75
|
keys.first[:key_data].should eql("AAAAB3NzaC1yc2EAAAADAQABAAABAQDwnMABQ9xWwYdhHaaoNSzFMfXmytWHgkBmDg6v8Fn3oILqOMs99IPd7ChPetDdUWYV2pzLVVKB/kwrcoodRC4H6YHn8xk1oI+gDsv4Yg7ytWwgnDf5zXwWMVQ/IqfOdfxRwS1UCrKL7UsVfIUPzXmkia7PoMoQNnM8jbDRDcfyis3Q1VZ9OjIlM/RfqjH0hGFS95nd6geNwpSbSpg4HxNmfltQ6GpoqclQXX0QdBO+q93sn33JjFPEhYuLvQcoea7Tl0zRY0AGQ9r7562QFlWqMmB+9YXcsZu2OZSk7t5a39jral0jEuEeJB56kb5ZUqRA1DJI5En09/WUPLCYprdb")
|
76
76
|
end
|
77
77
|
|
78
|
+
it "should be 0 ssh-keys if the ssh-directory doesn't exists" do
|
79
|
+
keys = Railshoster::Utilities.find_public_ssh_keys(File.join(File.dirname(__FILE__), "..", "..", "fakefs", "fake_dot_ssh", "this_does_not_exist"), :verbose => false)
|
80
|
+
keys.size.should be(0)
|
81
|
+
end
|
82
|
+
|
78
83
|
it "should select a public ssh key without a dialog if there is only a single valid key" do
|
79
84
|
key = Railshoster::Utilities.select_public_ssh_key(File.join(File.dirname(__FILE__), "..", "..", "fakefs", "fake_dot_ssh", "1_valid_key"), :verbose => false)
|
80
85
|
key[:format].should eql("ssh-rsa")
|
data/templates/h/deploy.rb.erb
CHANGED
@@ -6,9 +6,46 @@
|
|
6
6
|
#
|
7
7
|
###############################
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
def gemfile_exists?
|
10
|
+
File.exists? "Gemfile"
|
11
|
+
end
|
12
|
+
|
13
|
+
def gemfile_lock_exists?
|
14
|
+
File.exists? "Gemfile.lock"
|
15
|
+
end
|
16
|
+
|
17
|
+
def rails_version
|
18
|
+
if gemfile_exists?
|
19
|
+
rails_v = (Proc.new {
|
20
|
+
file = File.new("Gemfile", "r")
|
21
|
+
while (line = file.gets)
|
22
|
+
if line =~ /^\s*gem\s+[\"\']rails[\"\'].+/
|
23
|
+
version = line.scan(/(\d+)\.(\d+)\.(\d+)/).first.map {|x| x.to_i}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
file.close
|
27
|
+
version
|
28
|
+
}).call
|
29
|
+
else
|
30
|
+
rails_v = nil
|
31
|
+
end
|
32
|
+
return rails_v
|
33
|
+
end
|
34
|
+
|
35
|
+
def rails_version_supports_assets?
|
36
|
+
rails_v = rails_version
|
37
|
+
return rails_v != nil && rails_v[0] >= 3 && rails_v[1] >= 1
|
38
|
+
end
|
11
39
|
|
40
|
+
if gemfile_exists? && gemfile_lock_exists?
|
41
|
+
require 'bundler/capistrano'
|
42
|
+
end
|
43
|
+
|
44
|
+
#### Use the asset-pipeline
|
45
|
+
|
46
|
+
if rails_version_supports_assets?
|
47
|
+
load 'deploy/assets'
|
48
|
+
end
|
12
49
|
|
13
50
|
#### Personal Settings
|
14
51
|
## User and Password
|
@@ -54,9 +91,12 @@ set :use_sudo, false
|
|
54
91
|
set :deploy_to, "<%= app["deploy_to"] %>"
|
55
92
|
|
56
93
|
# live
|
57
|
-
|
58
|
-
role :
|
59
|
-
role :
|
94
|
+
<% app["h"].each do |ahost| %>
|
95
|
+
role :app, "<%= ahost %>"
|
96
|
+
role :web, "<%= ahost %>"
|
97
|
+
<% end %>
|
98
|
+
|
99
|
+
role :db, "<%= app["h"].first %>", :primary => true
|
60
100
|
|
61
101
|
# railshoster bundler settings
|
62
102
|
set :bundle_flags, "--deployment --binstubs"
|
@@ -72,7 +112,7 @@ namespace :deploy do
|
|
72
112
|
|
73
113
|
desc "Additional Symlinks ( database.yml, etc. )"
|
74
114
|
task :additional_symlink, :roles => :app do
|
75
|
-
run "ln -sf #{shared_path}/config/database.yml #{
|
115
|
+
run "ln -sf #{shared_path}/config/database.yml #{release_path}/config/database.yml"
|
76
116
|
end
|
77
117
|
end
|
78
118
|
|
@@ -85,4 +125,10 @@ namespace :railshoster do
|
|
85
125
|
end
|
86
126
|
end
|
87
127
|
|
88
|
-
|
128
|
+
if rails_version_supports_assets?
|
129
|
+
before "deploy:assets:precompile", "deploy:additional_symlink"
|
130
|
+
after "deploy:create_symlink", "deploy:migrate"
|
131
|
+
else
|
132
|
+
after "deploy:create_symlink", "deploy:additional_symlink", "deploy:migrate"
|
133
|
+
end
|
134
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: railshoster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 8
|
10
|
+
version: 0.6.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Julian Fischer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-07-05 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: bundler
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- lib/railshoster/init_ssh_helpers.rb
|
215
215
|
- lib/railshoster/init_validation_helpers.rb
|
216
216
|
- lib/railshoster/invalid_public_ssh_key_error.rb
|
217
|
+
- lib/railshoster/no_ssh_key_given_error.rb
|
217
218
|
- lib/railshoster/possibly_not_a_git_repo_error.rb
|
218
219
|
- lib/railshoster/unsupported_application_type_error.rb
|
219
220
|
- lib/railshoster/utilities.rb
|
@@ -264,22 +265,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
264
265
|
requirements: []
|
265
266
|
|
266
267
|
rubyforge_project: railshoster
|
267
|
-
rubygems_version: 1.8.
|
268
|
+
rubygems_version: 1.8.10
|
268
269
|
signing_key:
|
269
270
|
specification_version: 3
|
270
271
|
summary: RailsHoster Applicatoin Deployment Suite
|
271
|
-
test_files:
|
272
|
-
|
273
|
-
- spec/fakefs/bundler/mysql2/Gemfile.lock
|
274
|
-
- spec/fakefs/bundler/pg/Gemfile.lock
|
275
|
-
- spec/fakefs/database_yml/database.mysql.yml
|
276
|
-
- spec/fakefs/fake_dot_ssh/1_valid_key/bullshit.pub
|
277
|
-
- spec/fakefs/fake_dot_ssh/1_valid_key/id_rsa.pub
|
278
|
-
- spec/fakefs/fake_dot_ssh/2_valid_keys/github_rsa.pub
|
279
|
-
- spec/fakefs/fake_dot_ssh/2_valid_keys/id_dsa.pub
|
280
|
-
- spec/lib/railshoster/command_spec.rb
|
281
|
-
- spec/lib/railshoster/init_command_spec.rb
|
282
|
-
- spec/lib/railshoster/init_database_helpers_spec.rb
|
283
|
-
- spec/lib/railshoster/init_gem_helpers_spec.rb
|
284
|
-
- spec/lib/railshoster/utilities_spec.rb
|
285
|
-
- spec/spec_helper.rb
|
272
|
+
test_files: []
|
273
|
+
|