deprec 1.9.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. data/CHANGELOG +280 -0
  2. data/COPYING +19 -0
  3. data/LICENSE +339 -0
  4. data/README +152 -0
  5. data/THANKS +17 -0
  6. data/bin/depify +128 -0
  7. data/docs/EXAMPLE-installing_tracks.txt +41 -0
  8. data/docs/README.nagios +22 -0
  9. data/docs/README.rails +17 -0
  10. data/docs/config_gen_explained.txt +39 -0
  11. data/docs/{README.quickstart → deprec-1.x/deprec-1.x.quickstart} +4 -1
  12. data/docs/{building_edge_capistrano.txt → deprec-1.x/notes.txt} +6 -3
  13. data/docs/old/deprec_banner.gif +0 -0
  14. data/docs/windows_linux.txt +350 -0
  15. data/docs/xen/traffic_monitoring_with_vnstat.txt +95 -0
  16. data/docs/xen/xen-tools-notes.txt +31 -0
  17. data/docs/xen/xen_on_hardy.txt +39 -0
  18. data/lib/deprec.rb +8 -1
  19. data/lib/deprec/capistrano_extensions.rb +442 -0
  20. data/lib/deprec/recipes.rb +50 -233
  21. data/lib/deprec/recipes/aoe.rb +79 -0
  22. data/lib/deprec/recipes/app/mongrel.rb +213 -0
  23. data/lib/deprec/recipes/app/passenger.rb +197 -0
  24. data/lib/deprec/recipes/apt_mirror.rb +99 -0
  25. data/lib/deprec/recipes/ar_sendmail.rb +67 -0
  26. data/lib/deprec/recipes/canonical.rb +68 -0
  27. data/lib/deprec/recipes/db/mysql.rb +144 -0
  28. data/lib/deprec/recipes/db/postgresql.rb +104 -0
  29. data/lib/deprec/recipes/db/sqlite.rb +37 -0
  30. data/lib/deprec/recipes/ddclient.rb +51 -0
  31. data/lib/deprec/recipes/deprec.rb +199 -0
  32. data/lib/deprec/recipes/deprecated.rb +71 -0
  33. data/lib/deprec/recipes/example.rb +115 -0
  34. data/lib/deprec/recipes/git.rb +97 -0
  35. data/lib/deprec/recipes/gitosis.rb +48 -0
  36. data/lib/deprec/recipes/heartbeat.rb +138 -0
  37. data/lib/deprec/recipes/logrotate.rb +54 -0
  38. data/lib/deprec/recipes/lvm.rb +20 -0
  39. data/lib/deprec/recipes/memcache.rb +6 -2
  40. data/lib/deprec/recipes/monit.rb +143 -0
  41. data/lib/deprec/recipes/nagios.rb +305 -0
  42. data/lib/deprec/recipes/network.rb +93 -0
  43. data/lib/deprec/recipes/ntp.rb +103 -0
  44. data/lib/deprec/recipes/php.rb +58 -0
  45. data/lib/deprec/recipes/postfix.rb +115 -0
  46. data/lib/deprec/recipes/rails.rb +300 -55
  47. data/lib/deprec/recipes/ruby/mri.rb +55 -0
  48. data/lib/deprec/recipes/ruby/ree.rb +41 -0
  49. data/lib/deprec/recipes/sphinx.rb +86 -0
  50. data/lib/deprec/recipes/ssh.rb +85 -18
  51. data/lib/deprec/recipes/ssl.rb +55 -0
  52. data/lib/deprec/recipes/starling.rb +119 -0
  53. data/lib/deprec/recipes/svn.rb +163 -183
  54. data/lib/deprec/recipes/trac.rb +239 -62
  55. data/lib/deprec/recipes/ubuntu.rb +18 -100
  56. data/lib/deprec/recipes/users.rb +90 -0
  57. data/lib/deprec/recipes/utils.rb +58 -0
  58. data/lib/deprec/recipes/vnstat.rb +85 -0
  59. data/lib/deprec/recipes/web/apache.rb +119 -0
  60. data/lib/deprec/recipes/web/nginx.rb +172 -0
  61. data/lib/deprec/recipes/wordpress.rb +96 -0
  62. data/lib/deprec/recipes/wpmu.rb +103 -0
  63. data/lib/deprec/recipes/xen.rb +267 -0
  64. data/lib/deprec/recipes/xentools.rb +75 -0
  65. data/lib/deprec/templates/aoe/aoe-init +55 -0
  66. data/lib/deprec/templates/aoe/fence_aoemask +351 -0
  67. data/lib/deprec/templates/apache/namevirtualhosts.conf +5 -0
  68. data/lib/deprec/templates/apt/sources.list +18 -0
  69. data/lib/deprec/templates/apt_mirror/apt-mirror-cron +4 -0
  70. data/lib/deprec/templates/apt_mirror/mirror.list +33 -0
  71. data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +9 -0
  72. data/lib/deprec/templates/ar_sendmail/monit.conf.erb +5 -0
  73. data/lib/deprec/templates/ddclient/ddclient.conf.erb +11 -0
  74. data/lib/deprec/templates/ddclient/ddclient.erb +15 -0
  75. data/lib/deprec/templates/deprec/caprc.erb +14 -0
  76. data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
  77. data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
  78. data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
  79. data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
  80. data/lib/deprec/templates/mongrel/apache_vhost.erb +148 -0
  81. data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
  82. data/lib/deprec/{third_party/mongrel_cluster/resources/mongrel_cluster → templates/mongrel/mongrel_cluster-init-script} +19 -6
  83. data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
  84. data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
  85. data/lib/deprec/templates/mongrel/nginx_vhost.erb +41 -0
  86. data/lib/deprec/templates/monit/monit-init-script +104 -0
  87. data/lib/deprec/templates/monit/monitrc.erb +227 -0
  88. data/lib/deprec/templates/monit/nothing +0 -0
  89. data/lib/deprec/templates/mysql/create_databases.sql +20 -0
  90. data/lib/deprec/templates/mysql/database.yml.prod +6 -0
  91. data/lib/deprec/templates/mysql/database.yml.stage +6 -0
  92. data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
  93. data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
  94. data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
  95. data/lib/deprec/templates/nagios/cgi.cfg.erb +321 -0
  96. data/lib/deprec/templates/nagios/check_linux_free_memory.pl +118 -0
  97. data/lib/deprec/templates/nagios/check_mongrel_cluster.rb +82 -0
  98. data/lib/deprec/templates/nagios/commands.cfg.erb +240 -0
  99. data/lib/deprec/templates/nagios/contacts.cfg.erb +57 -0
  100. data/lib/deprec/templates/nagios/hosts.cfg.erb +143 -0
  101. data/lib/deprec/templates/nagios/htpasswd.users +1 -0
  102. data/lib/deprec/templates/nagios/localhost.cfg.erb +157 -0
  103. data/lib/deprec/templates/nagios/nagios.cfg.erb +1274 -0
  104. data/lib/deprec/templates/nagios/nagios_apache_vhost.conf.erb +45 -0
  105. data/lib/deprec/templates/nagios/nrpe.cfg.erb +210 -0
  106. data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
  107. data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
  108. data/lib/deprec/templates/nagios/services.cfg.erb +79 -0
  109. data/lib/deprec/templates/nagios/templates.cfg.erb +9 -0
  110. data/lib/deprec/templates/nagios/timeperiods.cfg.erb +94 -0
  111. data/lib/deprec/templates/network/hostname.erb +1 -0
  112. data/lib/deprec/templates/network/hosts.erb +2 -0
  113. data/lib/deprec/templates/network/interfaces.erb +18 -0
  114. data/lib/deprec/templates/network/resolv.conf.erb +6 -0
  115. data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
  116. data/lib/deprec/templates/nginx/mime.types.erb +70 -0
  117. data/lib/deprec/templates/nginx/nginx-init-script +62 -0
  118. data/lib/deprec/templates/nginx/nginx.conf.erb +125 -0
  119. data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
  120. data/lib/deprec/templates/nginx/nothing.conf +1 -0
  121. data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +41 -0
  122. data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
  123. data/lib/deprec/templates/passenger/apache_vhost.erb +21 -0
  124. data/lib/deprec/templates/passenger/passenger.conf.erb +21 -0
  125. data/lib/deprec/templates/passenger/passenger.load.erb +3 -0
  126. data/lib/deprec/templates/postfix/aliases.erb +3 -0
  127. data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
  128. data/lib/deprec/templates/{postfix_main.conf → postfix/main.cf.erb} +6 -8
  129. data/lib/deprec/templates/postfix/master.cf.erb +77 -0
  130. data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
  131. data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
  132. data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
  133. data/lib/deprec/templates/ssl/make-ssl-cert +138 -0
  134. data/lib/deprec/templates/ssl/ssl-cert-snakeoil.key +15 -0
  135. data/lib/deprec/templates/ssl/ssl-cert-snakeoil.pem +19 -0
  136. data/lib/deprec/templates/starling/monit.conf.erb +14 -0
  137. data/lib/deprec/templates/starling/starling-init-script.erb +71 -0
  138. data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
  139. data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
  140. data/lib/deprec/templates/trac/nginx_vhost.conf.erb +26 -0
  141. data/lib/deprec/templates/trac/trac.ini.erb +169 -0
  142. data/lib/deprec/templates/trac/trac_deprec.png +0 -0
  143. data/lib/deprec/templates/trac/tracd-init.erb +43 -0
  144. data/lib/deprec/templates/trac/users.htdigest.erb +0 -0
  145. data/lib/deprec/templates/vnstat/config.php +57 -0
  146. data/lib/deprec/templates/wordpress/apache2_wordpress_vhost.conf.erb +31 -0
  147. data/lib/deprec/templates/wordpress/wp-config.php.erb +31 -0
  148. data/lib/deprec/templates/wpmu/apache_vhost.conf.erb +13 -0
  149. data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
  150. data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
  151. data/lib/deprec/templates/xen/xend-init.erb +57 -0
  152. data/lib/deprec/templates/xen/xendomains.erb +137 -0
  153. data/lib/deprec/templates/xentools/15-disable-hwclock +40 -0
  154. data/lib/deprec/templates/xentools/40-setup-networking +145 -0
  155. data/lib/deprec/templates/xentools/xen-tools.conf.erb +276 -0
  156. data/lib/deprec/templates/xentools/xm.tmpl.erb +138 -0
  157. data/lib/deprec_cmd_completion.sh +26 -0
  158. data/lib/vmbuilder_plugins/all.rb +20 -0
  159. data/lib/vmbuilder_plugins/apt.rb +93 -0
  160. data/lib/vmbuilder_plugins/emerge.rb +76 -0
  161. data/lib/{deprec/third_party/vmbuilder/plugins → vmbuilder_plugins}/gem.rb +10 -17
  162. data/lib/{deprec/third_party/vmbuilder/plugins → vmbuilder_plugins}/std.rb +69 -19
  163. metadata +204 -55
  164. data/bin/deprec +0 -35
  165. data/docs/README.slicehost +0 -14
  166. data/docs/README.svn_trac +0 -19
  167. data/lib/deprec/capistrano_extensions/actor_extensions.rb +0 -89
  168. data/lib/deprec/capistrano_extensions/cli_extensions.rb +0 -38
  169. data/lib/deprec/capistrano_extensions/deprec_extensions.rb +0 -137
  170. data/lib/deprec/generators/deprec/USAGE +0 -11
  171. data/lib/deprec/generators/deprec/deprec_generator.rb +0 -24
  172. data/lib/deprec/generators/deprec/templates/deploy.rb +0 -90
  173. data/lib/deprec/generators/loader.rb +0 -20
  174. data/lib/deprec/recipes/apache.rb +0 -91
  175. data/lib/deprec/recipes/cache_svn.rb +0 -74
  176. data/lib/deprec/recipes/vmware.rb +0 -114
  177. data/lib/deprec/templates/trac.ini.erb +0 -106
  178. data/lib/deprec/third_party/THIRD_PARTY_README +0 -12
  179. data/lib/deprec/third_party/mongrel_cluster/LICENSE +0 -506
  180. data/lib/deprec/third_party/mongrel_cluster/recipes.rb +0 -96
  181. data/lib/deprec/third_party/railsmachine/LICENSE +0 -506
  182. data/lib/deprec/third_party/railsmachine/recipes/apache.rb +0 -92
  183. data/lib/deprec/third_party/railsmachine/recipes/mysql.rb +0 -73
  184. data/lib/deprec/third_party/railsmachine/recipes/templates/httpd-ssl.conf +0 -80
  185. data/lib/deprec/third_party/railsmachine/recipes/templates/httpd.conf +0 -57
  186. data/lib/deprec/third_party/vmbuilder/plugins.rb +0 -8
  187. data/lib/deprec/third_party/vmbuilder/plugins/apt.rb +0 -144
  188. data/resources/capistrano_include_dotfiles.patch +0 -17
@@ -0,0 +1,104 @@
1
+ # Copyright 2006-2008 by Saulius Grigaitis. All rights reserved.
2
+ # Backported from centostrano to deprec by Eric Harris-Braun.
3
+ Capistrano::Configuration.instance(:must_exist).load do
4
+ namespace :deprec do
5
+ namespace :postgresql do
6
+
7
+ # Installation
8
+ desc "Install postgresql"
9
+ task :install, :roles => :db do
10
+ install_deps
11
+ end
12
+
13
+ # Install dependencies for PostgreSQL
14
+ task :install_deps, :roles => :db do
15
+ apt.install( {:base => %w(postgresql postgresql-client libpq-dev)}, :stable )
16
+ end
17
+
18
+ # Configuration
19
+
20
+ SYSTEM_CONFIG_FILES[:postgresql] = [
21
+
22
+ {:template => "pg_hba.conf.erb",
23
+ :path => '/var/lib/pgsql/data/pg_hba.conf',
24
+ :mode => 0644,
25
+ :owner => 'root:root'}
26
+ ]
27
+
28
+ desc "Generate configuration file(s) for postgresql from template(s)"
29
+ task :config_gen do
30
+ SYSTEM_CONFIG_FILES[:postgresql].each do |file|
31
+ deprec2.render_template(:postgresql, file)
32
+ end
33
+ end
34
+
35
+ desc "Push postgresql config files to server"
36
+ task :config, :roles => :db do
37
+ deprec2.push_configs(:postgresql, SYSTEM_CONFIG_FILES[:postgresql])
38
+ end
39
+
40
+ task :activate, :roles => :db do
41
+ send(run_method, "update-rc.d postgresql-8.3 defaults")
42
+ end
43
+
44
+ task :deactivate, :roles => :db do
45
+ send(run_method, "update-rc.d -f postgresql-8.3 remove")
46
+ end
47
+
48
+ # Control
49
+
50
+ desc "Start PostgreSQL"
51
+ task :start, :roles => :db do
52
+ send(run_method, "/etc/init.d/postgresql-8.3 start")
53
+ end
54
+
55
+ desc "Stop PostgreSQL"
56
+ task :stop, :roles => :db do
57
+ send(run_method, "/etc/init.d/postgresql-8.3 stop")
58
+ end
59
+
60
+ desc "Restart PostgreSQL"
61
+ task :restart, :roles => :db do
62
+ send(run_method, "/etc/init.d/postgresql-8.3 restart")
63
+ end
64
+
65
+ desc "Reload PostgreSQL"
66
+ task :reload, :roles => :db do
67
+ send(run_method, "/etc/init.d/postgresql-8.3 reload")
68
+ end
69
+
70
+ task :backup, :roles => :db do
71
+ end
72
+
73
+ task :restore, :roles => :db do
74
+ end
75
+
76
+ desc "Create a PostgreSQL user"
77
+ task :create_user, :roles => :db do
78
+ cmd = "su - postgres -c \'createuser -P -D -A -E #{db_user}\'"
79
+ sudo cmd do |channel, stream, data|
80
+ if data =~ /^Enter password for new/
81
+ channel.send_data "#{db_password}\n"
82
+ end
83
+ if data =~ /^Enter it again:/
84
+ channel.send_data "#{db_password}\n"
85
+ end
86
+ if data =~ /^Shall the new role be allowed to create more new roles?/
87
+ channel.send_data "n\n"
88
+ end
89
+ end
90
+ end
91
+
92
+ desc "Create a PostgreSQL Database"
93
+ task :create_database, :roles => :db do
94
+ sudo "su - postgres -c \'createdb -O #{db_user} #{db_name}\'"
95
+ end
96
+
97
+ desc "Grant user access to Database"
98
+ task :grant_user_access_to_database, :roles => :db do
99
+ # sudo "what's the command for this using #{db_user} #{db_name}\'"
100
+ end
101
+
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,37 @@
1
+ # Copyright 2006-2009 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :sqlite do
5
+
6
+ desc "Install sqlite"
7
+ task :install, :roles => :db do
8
+ install_deps
9
+ gem2.install "sqlite3-ruby"
10
+ end
11
+
12
+ # install dependencies for nginx
13
+ task :install_deps, :roles => :db do
14
+ apt.install( {:base => %w(sqlite3 libsqlite3-ruby libsqlite3-dev)}, :stable )
15
+ end
16
+ end
17
+
18
+ desc "Create a PostgreSQL user"
19
+ task :create_user do
20
+ # Not needed for sqlite
21
+ # We need these stubs for deprec:rails:setup_database
22
+ end
23
+
24
+ desc "Create a PostgreSQL Database"
25
+ task :create_database do
26
+ # Not needed for sqlite
27
+ # We need these stubs for deprec:rails:setup_database
28
+ end
29
+
30
+ desc "Grant user access to Database"
31
+ task :grant_user_access_to_database do
32
+ # Not needed for sqlite
33
+ # We need these stubs for deprec:rails:setup_database
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,51 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :ddclient do
5
+
6
+ set(:ddclient_user) { Capistrano::CLI.ui.ask "Enter ddclient username" }
7
+ set(:ddclient_pass) { Capistrano::CLI.ui.ask "Enter ddclient password" }
8
+ set(:ddclient_domains) { Capistrano::CLI.ui.ask "Enter ddclient domain" }
9
+ set(:ddclient_interface) {
10
+ Capistrano::CLI.ui.ask "Enter ddclient interface" do |q|
11
+ q.default = 'eth0'
12
+ end
13
+ }
14
+
15
+ desc "Install ddclient"
16
+ task :install do
17
+ install_deps
18
+ end
19
+
20
+ # install dependencies for ddclient
21
+ task :install_deps do
22
+ apt.install( {:base => %w(ddclient)}, :stable )
23
+ end
24
+
25
+ SYSTEM_CONFIG_FILES[:ddclient] = [
26
+ { :template => "ddclient.conf.erb",
27
+ :path => '/etc/ddclient.conf',
28
+ :mode => 0600,
29
+ :owner => 'root:root'},
30
+
31
+ { :template => "ddclient.erb",
32
+ :path => '/etc/default/ddclient',
33
+ :mode => 0600,
34
+ :owner => 'root:root'}
35
+ ]
36
+
37
+ desc "Update system networking configuration"
38
+ task :config do
39
+ SYSTEM_CONFIG_FILES[:ddclient].each do |file|
40
+ deprec2.render_template(:ddclient, file.merge(:remote=>true))
41
+ end
42
+ start
43
+ end
44
+
45
+ task :start do
46
+ sudo '/etc/init.d/ddclient start'
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,199 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+
4
+ # Set the value if not already set
5
+ # This method is accessible to all recipe files
6
+ def self.default(name, *args, &block)
7
+ unless exists?(name)
8
+ set(name, *args, &block)
9
+ end
10
+ end
11
+
12
+ # Deprec checks here for local versions of config templates before it's own
13
+ set :local_template_dir, File.join('config','templates')
14
+
15
+ # The following two Constants contain details of the configuration
16
+ # files used by each service. They're used when generating config
17
+ # files from templates and when configs files are pushed out to servers.
18
+ #
19
+ # They are populated by the recipe file for each service
20
+ #
21
+ SYSTEM_CONFIG_FILES = {} # e.g. httpd.conf
22
+ PROJECT_CONFIG_FILES = {} # e.g. projectname-httpd-vhost.conf
23
+
24
+ # For each service, the details of the file to download and options
25
+ # to configure, build and install the service
26
+ SRC_PACKAGES = {} unless defined?(SRC_PACKAGES)
27
+
28
+ # Server options
29
+ CHOICES_RUBY_VM = [:mri, :ree]
30
+ CHOICES_WEBSERVER = [:nginx, :apache, :none]
31
+ CHOICES_APPSERVER = [:mongrel, :webrick, :passenger, :none]
32
+ CHOICES_DATABASE = [:mysql, :postgresql, :sqlite, :none]
33
+
34
+ # Service defaults
35
+ #
36
+ # The defaults below are legacy values to support older deployments.
37
+ # Newly generated deploy.rb files have use apache, passenger and ree
38
+ default :ruby_vm_type, :mri
39
+ default :web_server_type, :nginx
40
+ default :app_server_type, :mongrel
41
+ default :db_server_type, :mysql
42
+ #
43
+ # default(:web_server_type) do
44
+ # Capistrano::CLI.ui.choose do |menu|
45
+ # CHOICES_WEBSERVER.each {|c| menu.choice(c)}
46
+ # menu.header = "select webserver type"
47
+ # end
48
+ # end
49
+ #
50
+ # default(:app_server_type) do
51
+ # Capistrano::CLI.ui.choose do |menu|
52
+ # CHOICES_APPSERVER.each {|c| menu.choice(c)}
53
+ # menu.header = "select application server type"
54
+ # end
55
+ # end
56
+ #
57
+ # default(:db_server_type) do
58
+ # Capistrano::CLI.ui.choose do |menu|
59
+ # CHOICES_DATABASE.each {|c| menu.choice(c)}
60
+ # menu.header = "select database server type"
61
+ # end
62
+ # end
63
+
64
+ default(:application) do
65
+ Capistrano::CLI.ui.ask "enter name of project(no spaces)" do |q|
66
+ q.validate = /^[0-9a-z_]*$/
67
+ end
68
+ end
69
+
70
+ default(:domain) do
71
+ Capistrano::CLI.ui.ask "enter domain name for project" do |q|
72
+ q.validate = /^[0-9a-z_\.]*$/
73
+ end
74
+ end
75
+
76
+ default(:repository) do
77
+ Capistrano::CLI.ui.ask "enter repository URL for project" do |q|
78
+ # q.validate = //
79
+ end
80
+ end
81
+
82
+ # some tasks run commands requiring special user privileges on remote servers
83
+ # these tasks will run the commands with:
84
+ # :invoke_command "command", :via => run_method
85
+ # override this value if sudo is not an option
86
+ # in that case, your use will need the correct privileges
87
+ default :run_method, :sudo
88
+
89
+ default(:backup_dir) { '/var/backups'}
90
+
91
+ # XXX rails deploy stuff
92
+ set :apps_root, File.join( %w(/ opt apps) ) # parent dir for apps
93
+ default(:deploy_to) { File.join(apps_root, application) } # dir for current app
94
+ default(:current_path) { File.join(deploy_to, "current") }
95
+ default(:shared_path) { File.join(deploy_to, "shared") }
96
+
97
+ # XXX more rails deploy stuff?
98
+
99
+ default :user, ENV['USER'] # user who is deploying
100
+ default :group, 'deploy' # deployment group
101
+ default(:group_src) { group } # group ownership for src dir
102
+ default :src_dir, '/usr/local/src' # 3rd party src on servers lives here
103
+ default(:web_server_aliases) { domain.match(/^www/) ? [] : ["www.#{domain}"] }
104
+
105
+ # XXX for some reason this is causing "before deprec:rails:install" to be executed twice
106
+ on :load, 'deprec:connect_canonical_tasks'
107
+
108
+ namespace :deprec do
109
+
110
+ task :connect_canonical_tasks do
111
+ # link application specific recipes into canonical task names
112
+ # e.g. deprec:web:restart => deprec:nginx:restart
113
+
114
+
115
+ namespaces_to_connect = { :web => :web_server_type,
116
+ :app => :app_server_type,
117
+ :db => :db_server_type,
118
+ :ruby => :ruby_vm_type
119
+ }
120
+ metaclass = class << self; self; end # XXX unnecessary?
121
+ namespaces_to_connect.each do |server, choice|
122
+ server_type = send(choice).to_sym
123
+ if server_type != :none
124
+ metaclass.send(:define_method, server) { namespaces[server] } # XXX unnecessary?
125
+ namespaces[server] = deprec.send(server_type)
126
+ end
127
+ end
128
+ end
129
+
130
+ task :dump do
131
+ require 'yaml'
132
+ y variables
133
+ end
134
+
135
+ task :setup_src_dir do
136
+ deprec2.groupadd(group_src)
137
+ deprec2.add_user_to_group(user, group_src)
138
+ deprec2.create_src_dir
139
+ end
140
+
141
+ # Download all packages used by deprec to your local host.
142
+ # You can then push them to /usr/local/src on target hosts
143
+ # to save time and bandwidth rather than repeatedly downloading
144
+ # from the distribution sites.
145
+ task :update_src do
146
+ SRC_PACKAGES.each{|key, src_package|
147
+ current_dir = Dir.pwd
148
+ system "cd src/ && test -f #{src_package[:filename]} || wget --quiet --timestamping #{src_package[:url]}"
149
+ system "cd #{current_dir}"
150
+ }
151
+ end
152
+
153
+ # todo
154
+ #
155
+ # Copy files from src/ to /usr/local/src/ on remote hosts
156
+ task :push_src do
157
+ SRC_PACKAGES.each do |key, src_package|
158
+ deprec2.set_package_defaults(src_package)
159
+ file = File.join('src', src_package[:filename])
160
+ if File.exists?(file)
161
+ std.su_put(File.read(file), "#{src_dir}/#{src_package[:filename]}", '/tmp/')
162
+ end
163
+ end
164
+ end
165
+
166
+ task :list_src do
167
+ # XXX ugly line - look away
168
+ max_key_size = SRC_PACKAGES.keys.max{|a,b| a.to_s.size <=> b.to_s.size}.to_s.size
169
+ SRC_PACKAGES.each{|key, src_package|
170
+ deprec2.set_package_defaults(src_package)
171
+ puts "#{key}#{' '*(max_key_size+1-key.to_s.size)}: #{src_package[:url]}"
172
+ }
173
+ end
174
+
175
+ task :find_src do
176
+ # XXX ugly line - look away
177
+ max_key_size = SRC_PACKAGES.keys.max{|a,b| a.to_s.size <=> b.to_s.size}.to_s.size
178
+ SRC_PACKAGES.each{|key, src_package|
179
+ deprec2.set_package_defaults(src_package)
180
+ puts "#{key}#{' '*(max_key_size+1-key.to_s.size)}: #{src_package[:url]}"
181
+ puts `find . -name #{src_package[:filename]}`
182
+ puts
183
+ }
184
+ end
185
+
186
+ task :recover_src do
187
+ # XXX ugly line - look away
188
+ max_key_size = SRC_PACKAGES.keys.max{|a,b| a.to_s.size <=> b.to_s.size}.to_s.size
189
+ SRC_PACKAGES.each{|key, src_package|
190
+ puts "#{key}#{' '*(max_key_size+1-key.to_s.size)}: #{src_package[:url]}"
191
+ file = `find . -name #{src_package[:filename]}`.split[0]
192
+ `cp #{file} src/` if file
193
+ puts
194
+ }
195
+ end
196
+
197
+ end
198
+
199
+ end
@@ -0,0 +1,71 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+
4
+ # deprecated tasks from deprec1
5
+ # we're now using namespaces and some different naming conventions
6
+
7
+ # XXX use deprecated function to generate these dynamically
8
+
9
+ deprec2_isnt_backwards_compatible = <<-EOF
10
+
11
+ You've installed deprec2 but seem to be using a deprec1 command.
12
+
13
+ You have two options:
14
+
15
+ - install deprec-1.9.x and continue using deprec1
16
+
17
+ Instructions are available at http://www.deprec.org/
18
+
19
+ - use deprec2
20
+
21
+ EOF
22
+
23
+ cap2_warning = <<-EOF
24
+
25
+ You're using Capistrano 2 but using a deprecated cap1 command.
26
+
27
+ EOF
28
+
29
+ task :setup_admin_account do
30
+ puts deprec2_isnt_backwards_compatible
31
+ puts " Replace 'cap setup_admin_account' with 'cap deprec:users:add'"
32
+ puts
33
+ end
34
+
35
+ task :change_root_password do
36
+ puts deprec2_isnt_backwards_compatible
37
+ puts " Replace 'cap change_root_password' with 'cap deprec:users:passwd'"
38
+ puts
39
+ end
40
+
41
+ task :setup_ssh_keys do
42
+ puts deprec2_isnt_backwards_compatible
43
+ puts " Replace 'cap setup_ssh_keys' with 'cap deprec:ssh:setup_keys'"
44
+ puts
45
+ end
46
+
47
+ task :install_rails_stack do
48
+ puts deprec2_isnt_backwards_compatible
49
+ puts " Replace 'cap install_rails_stack' with 'cap deprec:rails:install_rails_stack'"
50
+ puts
51
+ end
52
+
53
+ task :setup do
54
+ puts deprec2_isnt_backwards_compatible
55
+ puts " Replace 'cap setup' with 'cap deploy:setup'"
56
+ puts
57
+ end
58
+
59
+ task :restart_apache do
60
+ puts deprec2_isnt_backwards_compatible
61
+ puts " Replace 'cap restart_apache' with 'cap deprec:apache:restart'"
62
+ puts
63
+ end
64
+
65
+ task :show_tasks do
66
+ puts deprec2_isnt_backwards_compatible
67
+ puts " Replace 'cap show-tasks' with 'cap -T'"
68
+ puts
69
+ end
70
+
71
+ end