deprec 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/docs/README.quickstart +1 -1
- data/lib/deprec/capistrano_extensions/cli_extensions.rb +6 -3
- data/lib/deprec/generators/deprec/templates/deploy.rb +13 -0
- data/lib/deprec/recipes.rb +3 -2
- data/lib/deprec/recipes/rails.rb +61 -0
- data/lib/deprec/recipes/svn.rb +16 -17
- data/lib/deprec/recipes/trac.rb +4 -2
- data/lib/deprec/templates/trac.ini.erb +1 -1
- metadata +3 -2
data/docs/README.quickstart
CHANGED
@@ -11,7 +11,7 @@ to log into the remote server manually. Capistrano does all the work.
|
|
11
11
|
# Install deprec on workstation
|
12
12
|
sudo gem install deprec --include-dependencies
|
13
13
|
echo 'require "deprec/recipes"' >> ~/.caprc
|
14
|
-
echo
|
14
|
+
echo "ssh_options[:keys] = %w(${HOME}/.ssh/id_dsa)" >> ~/.caprc
|
15
15
|
echo 'ssh_options[:paranoid] = false' >> ~/.caprc
|
16
16
|
echo 'ssh_options[:forward_agent] = true' >> ~/.caprc
|
17
17
|
|
@@ -19,12 +19,15 @@ module Capistrano
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def self.prompt(prompt="Password
|
22
|
+
def self.prompt(prompt="Password", default=nil)
|
23
23
|
sync = STDOUT.sync
|
24
24
|
begin
|
25
25
|
STDOUT.sync = true
|
26
|
-
print(prompt)
|
27
|
-
|
26
|
+
print("#{prompt}")
|
27
|
+
print " [#{default}]" if default
|
28
|
+
print ': '
|
29
|
+
response = STDIN.gets.chomp
|
30
|
+
response == '' ? default : response
|
28
31
|
ensure
|
29
32
|
STDOUT.sync = sync
|
30
33
|
puts
|
@@ -34,6 +34,19 @@ set :rails_env, "production"
|
|
34
34
|
# Automatically symlink these directories from current/public to shared/public.
|
35
35
|
# set :app_symlinks, %w{photo, document, asset}
|
36
36
|
|
37
|
+
# =============================================================================
|
38
|
+
# SPECIAL OPTIONS
|
39
|
+
# =============================================================================
|
40
|
+
# These options allow you to tweak deprec behaviour
|
41
|
+
|
42
|
+
# If you do not keep database.yml in source control, set this to false.
|
43
|
+
# After new code is deployed, deprec will symlink current/config/database.yml
|
44
|
+
# to shared/config/database.yml
|
45
|
+
#
|
46
|
+
# You can generate shared/config/database.yml with 'cap generate_database_yml'
|
47
|
+
#
|
48
|
+
# set :database_yml_in_scm, true
|
49
|
+
|
37
50
|
# =============================================================================
|
38
51
|
# APACHE OPTIONS
|
39
52
|
# =============================================================================
|
data/lib/deprec/recipes.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'deprec/recipes/ssh'
|
2
2
|
require 'deprec/recipes/svn'
|
3
3
|
require 'deprec/recipes/trac'
|
4
|
+
require 'deprec/recipes/rails'
|
4
5
|
require 'deprec/recipes/ubuntu'
|
5
6
|
require 'deprec/recipes/apache'
|
6
7
|
require 'deprec/recipes/memcache'
|
@@ -13,7 +14,7 @@ require 'deprec/capistrano_extensions/deprec_extensions.rb'
|
|
13
14
|
require 'deprec/capistrano_extensions/actor_extensions.rb'
|
14
15
|
|
15
16
|
Capistrano.configuration(:must_exist).load do
|
16
|
-
set :application, lambda { Capistrano::CLI.prompt "Enter application name
|
17
|
+
set :application, lambda { Capistrano::CLI.prompt "Enter application name" }
|
17
18
|
set :user, (defined?(user) ? user : ENV['USER']) # user who is deploying
|
18
19
|
set :group, 'deploy' # deployment group
|
19
20
|
set :src_dir, (defined?(src_dir) ? src_dir : '/usr/local/src') # 3rd party src on servers
|
@@ -210,7 +211,7 @@ Capistrano.configuration(:must_exist).load do
|
|
210
211
|
end
|
211
212
|
|
212
213
|
task :setup_admin_account do
|
213
|
-
user = Capistrano::CLI.prompt "Enter userid for new user
|
214
|
+
user = Capistrano::CLI.prompt "Enter userid for new user"
|
214
215
|
deprec.useradd(user, :shell => '/bin/bash')
|
215
216
|
puts "Setting pasword for new account"
|
216
217
|
sudo_with_input("passwd #{user}", /UNIX password/) # ??? how many versions of the prompt are there?
|
@@ -0,0 +1,61 @@
|
|
1
|
+
Capistrano.configuration(:must_exist).load do
|
2
|
+
|
3
|
+
set :database_yml_in_scm, true
|
4
|
+
|
5
|
+
# database.yml stuff
|
6
|
+
#
|
7
|
+
# XXX DRY this up
|
8
|
+
# I don't know how to let :gen_db_yml check if values have been set.
|
9
|
+
#
|
10
|
+
# if (self.respond_to?("db_host_#{rails_env}".to_sym)) # doesn't seem to work
|
11
|
+
|
12
|
+
set :db_host_default, lambda { Capistrano::CLI.prompt 'Enter database host', 'localhost'}
|
13
|
+
set :db_host_staging, lambda { db_host_default }
|
14
|
+
set :db_host_production, lambda { db_host_default }
|
15
|
+
|
16
|
+
set :db_name_default, lambda { Capistrano::CLI.prompt 'Enter database name', "#{application}_#{rails_env}" }
|
17
|
+
set :db_name_staging, lambda { db_name_default }
|
18
|
+
set :db_name_production, lambda { db_name_default }
|
19
|
+
|
20
|
+
set :db_user_default, lambda { Capistrano::CLI.prompt 'Enter database user', 'root' }
|
21
|
+
set :db_user_staging, lambda { db_user_default }
|
22
|
+
set :db_user_production, lambda { db_user_default }
|
23
|
+
|
24
|
+
set :db_pass_default, lambda { Capistrano::CLI.prompt 'Enter database pass', '' }
|
25
|
+
set :db_pass_staging, lambda { db_pass_default }
|
26
|
+
set :db_pass_production, lambda { db_pass_default }
|
27
|
+
|
28
|
+
set :db_adaptor_default, lambda { Capistrano::CLI.prompt 'Enter database adaptor', 'mysql' }
|
29
|
+
set :db_adaptor_staging, lambda { db_adaptor_default }
|
30
|
+
set :db_adaptor_production, lambda { db_adaptor_default }
|
31
|
+
|
32
|
+
set :db_socket_default, lambda { Capistrano::CLI.prompt('Enter database socket', '')}
|
33
|
+
set :db_socket_staging, lambda { db_socket_default }
|
34
|
+
set :db_socket_production, lambda { db_socket_default }
|
35
|
+
|
36
|
+
|
37
|
+
task :generate_database_yml, :roles => :app do
|
38
|
+
database_configuration = render :template => <<-EOF
|
39
|
+
#{rails_env}:
|
40
|
+
adapter: #{self.send("db_adaptor_#{rails_env}")}
|
41
|
+
database: #{self.send("db_name_#{rails_env}")}
|
42
|
+
username: #{self.send("db_user_#{rails_env}")}
|
43
|
+
password: #{self.send("db_pass_#{rails_env}")}
|
44
|
+
host: #{self.send("db_host_#{rails_env}")}
|
45
|
+
socket: #{self.send("db_socket_#{rails_env}")}
|
46
|
+
EOF
|
47
|
+
run "mkdir -p #{deploy_to}/#{shared_dir}/config"
|
48
|
+
put database_configuration, "#{deploy_to}/#{shared_dir}/config/database.yml"
|
49
|
+
end
|
50
|
+
|
51
|
+
task :after_update_code, :roles => :app do
|
52
|
+
symlink_database_yml unless database_yml_in_scm
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Link in the production database.yml"
|
56
|
+
task :symlink_database_yml, :roles => :app do
|
57
|
+
run "rm -f #{current_path}/config/database.yml"
|
58
|
+
run "ln -nfs #{deploy_to}/#{shared_dir}/config/database.yml #{release_path}/config/database.yml"
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
data/lib/deprec/recipes/svn.rb
CHANGED
@@ -34,13 +34,13 @@ Capistrano.configuration(:must_exist).load do
|
|
34
34
|
elsif ENV['HOSTS']
|
35
35
|
svn_host = ENV['HOSTS']
|
36
36
|
else
|
37
|
-
Capistrano::CLI.
|
37
|
+
Capistrano::CLI.prompt('svn host')
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
# This is the actual path in the svn repos where we'll check our project into
|
42
42
|
set (:repos_path) do
|
43
|
-
repository ? URI.parse(repository).path : Capistrano::CLI.
|
43
|
+
repository ? URI.parse(repository).path : Capistrano::CLI.prompt('svn repos path')
|
44
44
|
end
|
45
45
|
|
46
46
|
# We'll calculate this based on the repos_path. It's used when initializing the repository
|
@@ -51,11 +51,14 @@ Capistrano.configuration(:must_exist).load do
|
|
51
51
|
# account name to perform actions on
|
52
52
|
# this is a hack to allow us to optionally pass a variable to tasks
|
53
53
|
set (:svn_account) do
|
54
|
-
Capistrano::CLI.prompt('account name
|
54
|
+
Capistrano::CLI.prompt('account name')
|
55
55
|
end
|
56
56
|
|
57
|
-
#
|
58
|
-
#
|
57
|
+
# I'd like to be able to construct :repository if it's not explicitly set
|
58
|
+
# However we're grabbing values from it in the lines above so it would get a bit recursive
|
59
|
+
# set :repository, lambda { "#{svn_scheme}://#{scm_host == 'localhost' ? '/' : user+'@'+scm_host}#{repos_path}" }
|
60
|
+
|
61
|
+
# XXX requires apache to have already been installed...
|
59
62
|
desc "install Subversion version control system"
|
60
63
|
task :svn_install, :roles => :scm do
|
61
64
|
# svn 1.4 server improves on 1.3 and is backwards compatible with 1.3 clients
|
@@ -104,27 +107,24 @@ Capistrano.configuration(:must_exist).load do
|
|
104
107
|
deprec.add_user_to_group(svn_account, scm_group)
|
105
108
|
end
|
106
109
|
|
107
|
-
|
108
|
-
|
110
|
+
desc "Create subversion repository and import project into it"
|
111
|
+
task :svn_setup, :roles => :scm do
|
112
|
+
svn_create_repos
|
113
|
+
svn_import
|
109
114
|
end
|
110
115
|
|
111
|
-
task :
|
112
|
-
|
116
|
+
task :scm_setup, :roles => :scm do # deprecated
|
117
|
+
svn_setup
|
113
118
|
end
|
114
119
|
|
115
|
-
|
116
|
-
|
117
|
-
svn_create_repos
|
118
|
-
svn_import
|
120
|
+
task :svn_import_project, :roles => :scm do # deprecated
|
121
|
+
svn_setup
|
119
122
|
end
|
120
123
|
|
121
124
|
desc "Create a subversion repository"
|
122
125
|
task :svn_create_repos, :roles => :scm do
|
123
126
|
set :svn_account, user
|
124
127
|
svn_grant_user_access
|
125
|
-
# deprec.useradd(user)
|
126
|
-
# deprec.groupadd(scm_group)
|
127
|
-
# deprec.add_user_to_group(user, scm_group)
|
128
128
|
deprec.mkdir(repos_root, :mode => '2775', :group => scm_group)
|
129
129
|
sudo "svnadmin verify #{repos_root} > /dev/null 2>&1 || sudo svnadmin create #{repos_root}"
|
130
130
|
sudo "chmod -R g+w #{repos_root}"
|
@@ -133,7 +133,6 @@ Capistrano.configuration(:must_exist).load do
|
|
133
133
|
# Adapted from code in Bradley Taylors RailsMachine gem
|
134
134
|
desc "Import project into subversion repository."
|
135
135
|
task :svn_import, :roles => :scm do
|
136
|
-
repository ||= "#{svn_scheme}://#{scm_host == 'localhost' ? '/' : scm_host}/#{repos_path}"
|
137
136
|
new_path = "../#{application}"
|
138
137
|
tags = repository.sub("trunk", "tags")
|
139
138
|
branches = repository.sub("trunk", "branches")
|
data/lib/deprec/recipes/trac.rb
CHANGED
@@ -4,13 +4,15 @@ Capistrano.configuration(:must_exist).load do
|
|
4
4
|
set :trac_pidfile, lambda { "#{deploy_to}/shared/pids/trac.pid" }
|
5
5
|
set :tracd_port, '9000'
|
6
6
|
set (:trac_path) do
|
7
|
-
deploy_to ? "#{deploy_to}/trac" : Capistrano::CLI.prompt('path to trac config
|
7
|
+
deploy_to ? "#{deploy_to}/trac" : Capistrano::CLI.prompt('path to trac config')
|
8
8
|
end
|
9
9
|
set (:trac_account) do
|
10
|
-
Capistrano::CLI.prompt('enter new trac user account name
|
10
|
+
Capistrano::CLI.prompt('enter new trac user account name')
|
11
11
|
end
|
12
12
|
set :trac_passwordfile_exists, true # hack - should check on remote system instead
|
13
13
|
|
14
|
+
set :trac_smtp_enabled, true
|
15
|
+
|
14
16
|
task :trac_install, :roles => :scm do
|
15
17
|
version = 'trac-0.10.4'
|
16
18
|
set :src_package, {
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: deprec
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date: 2007-06-
|
6
|
+
version: 1.9.0
|
7
|
+
date: 2007-06-28 00:00:00 +10:00
|
8
8
|
summary: deployment recipes for capistrano
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- lib/deprec/recipes/apache.rb
|
54
54
|
- lib/deprec/recipes/cache_svn.rb
|
55
55
|
- lib/deprec/recipes/memcache.rb
|
56
|
+
- lib/deprec/recipes/rails.rb
|
56
57
|
- lib/deprec/recipes/ssh.rb
|
57
58
|
- lib/deprec/recipes/svn.rb
|
58
59
|
- lib/deprec/recipes/trac.rb
|