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,172 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :nginx do
5
+
6
+ set :nginx_server_name, nil
7
+ set :nginx_user, 'nginx'
8
+ set :nginx_group, 'nginx'
9
+ set :nginx_vhost_dir, '/usr/local/nginx/conf/vhosts'
10
+ set :nginx_client_max_body_size, '100M'
11
+ set :nginx_worker_processes, 4
12
+
13
+ SRC_PACKAGES[:nginx] = {
14
+ :url => "http://sysoev.ru/nginx/nginx-0.5.34.tar.gz",
15
+ :md5sum => "8f7d3efcd7caaf1f06e4d95dfaeac238 nginx-0.5.34.tar.gz",
16
+ :configure => './configure --sbin-path=/usr/local/sbin --with-http_ssl_module;'
17
+ }
18
+
19
+ desc "Install nginx"
20
+ task :install, :roles => :web do
21
+ install_deps
22
+ deprec2.download_src(SRC_PACKAGES[:nginx], src_dir)
23
+ deprec2.install_from_src(SRC_PACKAGES[:nginx], src_dir)
24
+ create_nginx_user
25
+ initial_config
26
+ activate
27
+ start
28
+ end
29
+
30
+ # install dependencies for nginx
31
+ task :install_deps, :roles => :web do
32
+ apt.install( {:base => %w(libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev)}, :stable )
33
+ # do we need libgcrypt11-dev?
34
+ end
35
+
36
+ task :create_nginx_user, :roles => :web do
37
+ deprec2.groupadd(nginx_group)
38
+ deprec2.useradd(nginx_user, :group => nginx_group, :homedir => false)
39
+ end
40
+
41
+ SYSTEM_CONFIG_FILES[:nginx] = [
42
+
43
+ {:template => 'nginx-init-script',
44
+ :path => '/etc/init.d/nginx',
45
+ :mode => 0755,
46
+ :owner => 'root:root'},
47
+
48
+ {:template => 'nginx.conf.erb',
49
+ :path => "/usr/local/nginx/conf/nginx.conf",
50
+ :mode => 0644,
51
+ :owner => 'root:root'},
52
+
53
+ {:template => 'mime.types.erb',
54
+ :path => "/usr/local/nginx/conf/mime.types",
55
+ :mode => 0644,
56
+ :owner => 'root:root'},
57
+
58
+ {:template => 'nothing.conf',
59
+ :path => "/usr/local/nginx/conf/vhosts/nothing.conf",
60
+ :mode => 0644,
61
+ :owner => 'root:root'}
62
+ ]
63
+
64
+ PROJECT_CONFIG_FILES[:nginx] = [
65
+
66
+ {:template => 'logrotate.conf.erb',
67
+ :path => "logrotate.conf",
68
+ :mode => 0644,
69
+ :owner => 'root:root'}
70
+ ]
71
+
72
+ task :initial_config, :roles => :web do
73
+ SYSTEM_CONFIG_FILES[:nginx].each do |file|
74
+ deprec2.render_template(:nginx, file.merge(:remote => true))
75
+ end
76
+ end
77
+
78
+ desc <<-DESC
79
+ Generate nginx config from template. Note that this does not
80
+ push the config to the server, it merely generates required
81
+ configuration files. These should be kept under source control.
82
+ The can be pushed to the server with the :config task.
83
+ DESC
84
+ task :config_gen do
85
+ SYSTEM_CONFIG_FILES[:nginx].each do |file|
86
+ deprec2.render_template(:nginx, file)
87
+ end
88
+ end
89
+
90
+ desc "Generate config files for rails app."
91
+ task :config_gen_project do
92
+ PROJECT_CONFIG_FILES[:nginx].each do |file|
93
+ deprec2.render_template(:nginx, file)
94
+ end
95
+ end
96
+
97
+ desc "Push nginx config files to server"
98
+ task :config, :roles => :web do
99
+ deprec2.push_configs(:nginx, SYSTEM_CONFIG_FILES[:nginx])
100
+ end
101
+
102
+ desc "Push out config files for rails app."
103
+ task :config_project, :roles => :web do
104
+ deprec2.push_configs(:nginx, PROJECT_CONFIG_FILES[:nginx])
105
+ end
106
+
107
+ desc <<-DESC
108
+ Activate nginx start scripts on server.
109
+ Setup server to start nginx on boot.
110
+ DESC
111
+ task :activate, :roles => :web do
112
+ activate_system
113
+ end
114
+
115
+ task :activate_system, :roles => :web do
116
+ send(run_method, "update-rc.d nginx defaults")
117
+ end
118
+
119
+ desc <<-DESC
120
+ Dectivate nginx start scripts on server.
121
+ Setup server to start nginx on boot.
122
+ DESC
123
+ task :deactivate, :roles => :web do
124
+ send(run_method, "update-rc.d -f nginx remove")
125
+ end
126
+
127
+ # Control
128
+
129
+ desc "Start Nginx"
130
+ task :start, :roles => :web do
131
+ # Nginx returns error code if you try to start it when it's already running
132
+ # We don't want this to kill Capistrano.
133
+ send(run_method, "/etc/init.d/nginx start; exit 0")
134
+ end
135
+
136
+ desc "Stop Nginx"
137
+ task :stop, :roles => :web do
138
+ # Nginx returns error code if you try to stop when it's not running
139
+ # We don't want this to kill Capistrano.
140
+ send(run_method, "/etc/init.d/nginx stop; exit 0")
141
+ end
142
+
143
+ desc "Restart Nginx"
144
+ task :restart, :roles => :web do
145
+ stop
146
+ start
147
+ end
148
+
149
+ desc "Reload Nginx"
150
+ task :reload, :roles => :web do
151
+ # Nginx returns error code if you try to reload when it's not running
152
+ # We don't want this to kill Capistrano.
153
+ send(run_method, "/etc/init.d/nginx reload; exit 0")
154
+ end
155
+
156
+ task :backup, :roles => :web do
157
+ # there's nothing to backup for nginx
158
+ end
159
+
160
+ task :restore, :roles => :web do
161
+ # there's nothing to store for nginx
162
+ end
163
+
164
+ # Helper task to get rid of pesky "it works" page - not called by deprec tasks
165
+ task :rename_index_page, :roles => :web do
166
+ index_file = '/usr/local/nginx/html/index.html'
167
+ sudo "test -f #{index_file} && sudo mv #{index_file} #{index_file}.orig || exit 0"
168
+ end
169
+
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,96 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+
4
+ require 'digest'
5
+
6
+ set :application, 'wordpress'
7
+ set(:wordpress_domain) { Capistrano::CLI.ui.ask 'Enter domain wordpress will be served on' }
8
+ set :db_name, 'wordpress'
9
+ set :db_user, 'wordpress'
10
+ set(:db_pass) { Capistrano::CLI.ui.ask 'Enter db password for wordpress' }
11
+ set(:db_host) { Capistrano::CLI.ui.ask 'Enter db hostname for wordpress' }
12
+ set :db_charset, 'utf8'
13
+ set :db_collate, ''
14
+
15
+ set(:auth_key) { Digest::SHA1.hexdigest srand.to_s }
16
+ set(:secure_auth_key) { Digest::SHA1.hexdigest srand.to_s }
17
+ set(:logged_in_key) { Digest::SHA1.hexdigest srand.to_s }
18
+
19
+ set(:wordpress_install_dir) { "#{deploy_to}/public" }
20
+
21
+
22
+ namespace :deprec do
23
+ namespace :wordpress do
24
+
25
+ SRC_PACKAGES[:wordpress] =
26
+ {
27
+ :url => "http://wordpress.org/latest.tar.gz",
28
+ :dir => 'wordpress'
29
+ }
30
+
31
+ desc "Install Wordpress"
32
+ task :install do
33
+ install_deps unless ENV['SKIP_DEPS'] # save time by skipping deps (when reinstalling)
34
+ deprec2.download_src(SRC_PACKAGES[:wordpress], src_dir)
35
+ deprec2.unpack_src(SRC_PACKAGES[:wordpress], src_dir)
36
+ deprec2.mkdir wordpress_install_dir, :via => :sudo
37
+ sudo "cp -r #{src_dir}/wordpress/* #{wordpress_install_dir}/"
38
+ end
39
+
40
+ task :install_deps do
41
+ top.deprec.apache.install
42
+ top.deprec.php.install
43
+ end
44
+
45
+ PROJECT_CONFIG_FILES[:wordpress] = [
46
+
47
+ {:template => "wp-config.php.erb",
48
+ :path => 'wp-config.php',
49
+ :mode => 0755,
50
+ :owner => 'root:root'},
51
+
52
+ {:template => "apache2_wordpress_vhost.conf.erb",
53
+ :path => 'apache2_wordpress_vhost.conf',
54
+ :mode => 0755,
55
+ :owner => 'root:root'}
56
+
57
+ ]
58
+
59
+ desc "Generate configuration file(s) for mongrel from template(s)"
60
+ task :config_gen do
61
+ config_gen_project
62
+ end
63
+
64
+ task :config_gen_project do
65
+ PROJECT_CONFIG_FILES[:wordpress].each do |file|
66
+ deprec2.render_template(:wordpress, file)
67
+ end
68
+ end
69
+
70
+ desc "Push wordpress config files to server"
71
+ task :config, :roles => :wordpress do
72
+ config_project
73
+ end
74
+
75
+ task :config_project, :roles => :wordpress do
76
+ deprec2.push_configs(:wordpress, PROJECT_CONFIG_FILES[:wordpress])
77
+ sudo "ln -sf #{deploy_to}/wordpress/wp-config.php #{wordpress_install_dir}/wp-config.php"
78
+ sudo "ln -sf #{deploy_to}/wordpress/apache2_wordpress_vhost.conf #{apache_vhost_dir}/#{application}.conf"
79
+ end
80
+
81
+ desc <<-EOF
82
+ Create a database for WordPress on your web server, as well as
83
+ a MySQL user who has all privileges for accessing and modifying it.
84
+ EOF
85
+ task :create_database, :roles => lambda { db_host } do
86
+ run <<-EOF
87
+ mysql -u root -e 'create database #{DB_NAME}'
88
+ mysql -u root -e 'grant all on #{DB_NAME}.* to '#{DB_USER}'@'%' identified by '#{DB_PASSWORD}'
89
+ mysql -u root -e 'flush privileges'
90
+ EOF
91
+ end
92
+
93
+ end
94
+ end
95
+
96
+ end
@@ -0,0 +1,103 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+
4
+ require 'digest'
5
+
6
+ set :wpmu_root, '/var/www/wpmu'
7
+ set(:wpmu_domain) { Capistrano::CLI.ui.ask 'Enter domain wordpress will be served on' }
8
+
9
+ namespace :deprec do
10
+ namespace :wpmu do
11
+
12
+ SRC_PACKAGES[:wpmu] =
13
+ {
14
+ :url => "http://mu.wordpress.org/latest.tar.gz",
15
+ :dir => 'wordpress-mu'
16
+ }
17
+
18
+ desc "Install Wordpress"
19
+ task :install, :roles => :wpmu do
20
+ install_deps
21
+ deprec2.download_src(SRC_PACKAGES[:wpmu], src_dir)
22
+ deprec2.unpack_src(SRC_PACKAGES[:wpmu], src_dir)
23
+ sudo "test -d #{wpmu_root} && #{sudo} rm -fr #{wpmu_root}; exit 0;"
24
+ sudo "mv #{src_dir}/wordpress-mu #{wpmu_root}"
25
+ initial_config
26
+ sudo "a2ensite wpmu"
27
+ top.deprec.apache.reload
28
+ manual_instructions
29
+ end
30
+
31
+ task :manual_instructions do
32
+ puts <<-DESC
33
+
34
+ Run something like the following mysql commands on your datbase server:
35
+
36
+ drop database wpmu;
37
+ create database wpmu;
38
+ grant all on wpmu.* to 'wpmu'@'%' identified by 'wpmu';
39
+ flush privileges;
40
+
41
+ Then run:
42
+
43
+ cap deprec:wpmu:make_insecure
44
+
45
+ Setup database access via the webpage at:
46
+
47
+ http://#{wpmu_domain}/
48
+
49
+ Then run:
50
+
51
+ cap deprec:wpmu:make_secure
52
+
53
+ DESC
54
+ end
55
+
56
+ task :install_deps, :roles => :wpmu do
57
+ top.deprec.apache.install
58
+ sudo "a2enmod rewrite"
59
+ top.deprec.php.install
60
+ end
61
+
62
+ PROJECT_CONFIG_FILES[:wpmu] = [
63
+
64
+ {:template => "apache_vhost.conf.erb",
65
+ :path => '/etc/apache2/sites-available/wpmu',
66
+ :mode => 0755,
67
+ :owner => 'root:root'}
68
+
69
+ ]
70
+
71
+ desc "Generate configuration file(s) for wpmu from template(s)"
72
+ task :config_gen do
73
+ PROJECT_CONFIG_FILES[:wpmu].each do |file|
74
+ deprec2.render_template(:wpmu, file)
75
+ end
76
+ end
77
+
78
+ desc "Push wordpress config files to server"
79
+ task :config, :roles => :wpmu do
80
+ deprec2.push_configs(:wpmu, SYSTEM_CONFIG_FILES[:wpmu])
81
+ end
82
+
83
+ # Push direct to remote
84
+ task :initial_config, :roles => :wpmu do
85
+ PROJECT_CONFIG_FILES[:wpmu].each do |file|
86
+ deprec2.render_template(:wpmu, file.merge(:remote => true))
87
+ end
88
+ end
89
+
90
+ # Set permissions to allow wpmu to write config files
91
+ task :make_insecure, :roles => :wpmu do
92
+ sudo "chmod 777 #{wpmu_root} #{wpmu_root}/wp-content"
93
+ end
94
+
95
+ # Reverse the previous command
96
+ task :make_secure, :roles => :wpmu do
97
+ sudo "chmod 755 #{wpmu_root} #{wpmu_root}/wp-content"
98
+ end
99
+
100
+ end
101
+ end
102
+
103
+ end
@@ -0,0 +1,267 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :xen do
5
+
6
+ # Config variables for migration
7
+ default(:xen_slice) { Capistrano::CLI.ui.ask("Slice name") }
8
+ default(:xen_old_host) { Capistrano::CLI.ui.ask("Old Xen host") }
9
+ default(:xen_new_host) { Capistrano::CLI.ui.ask("New Xen host") }
10
+ set(:xen_disk_size) { Capistrano::CLI.ui.ask("Disk size (GB)") }
11
+ set(:xen_swap_size) { Capistrano::CLI.ui.ask("Swap size (GB)") }
12
+
13
+ # ref: http://www.eadz.co.nz/blog/article/xen-gutsy.html
14
+
15
+ desc "Install Xen"
16
+ task :install, :roles => :dom0 do
17
+ install_deps
18
+ disable_apparmour
19
+ disable_tls
20
+ enable_hardy_domu
21
+ initial_config
22
+ end
23
+
24
+ task :install_deps, :roles => :dom0 do
25
+ # for amd64 version of ubuntu 7.10
26
+ apt.install( {:base => %w(linux-image-xen bridge-utils libxen3.1 python-xen-3.1 xen-docs-3.1 xen-hypervisor-3.1 xen-ioemu-3.1 xen-tools xen-utils-3.1 lvm2)}, :stable )
27
+ # alternatively, for x86 version of ubuntu:
28
+ # apt-get install ubuntu-xen-server libc6-xen lvm2
29
+ end
30
+
31
+ task :disable_apparmour, :roles => :dom0 do
32
+ sudo '/etc/init.d/apparmor stop'
33
+ sudo 'update-rc.d -f apparmor remove'
34
+ end
35
+
36
+ task :disable_tls, :roles => :dom0 do
37
+ sudo 'mv /lib/tls /lib/tls.disabled'
38
+ end
39
+
40
+ SYSTEM_CONFIG_FILES[:xen] = [
41
+
42
+ {:template => "xend-config.sxp.erb",
43
+ :path => '/etc/xen/xend-config.sxp',
44
+ :mode => 0644,
45
+ :owner => 'root:root'},
46
+
47
+ {:template => "xendomains.erb",
48
+ :path => '/etc/default/xendomains',
49
+ :mode => 0755,
50
+ :owner => 'root:root'},
51
+
52
+ # This gives you a second network bridge on second ethernet device
53
+ {:template => "network-bridge-wrapper",
54
+ :path => '/etc/xen/scripts/network-bridge-wrapper',
55
+ :mode => 0755,
56
+ :owner => 'root:root'},
57
+
58
+ # Bugfix for gutsy - xendomains fails to shut down domains on system shutdown
59
+ {:template => "xend-init.erb",
60
+ :path => '/etc/init.d/xend',
61
+ :mode => 0755,
62
+ :owner => 'root:root'}
63
+
64
+ ]
65
+
66
+ desc "Push Xen config files to server"
67
+ task :initial_config, :roles => :dom0 do
68
+ # Non-standard! We're pushing these straight out
69
+ SYSTEM_CONFIG_FILES[:xen].each do |file|
70
+ deprec2.render_template(:xen, file.merge(:remote => true))
71
+ end
72
+ end
73
+
74
+ desc "Generate configuration file(s) for Xen from template(s)"
75
+ task :config_gen do
76
+ SYSTEM_CONFIG_FILES[:xen].each do |file|
77
+ deprec2.render_template(:xen, file)
78
+ end
79
+ end
80
+
81
+ desc "Push Xen config files to server"
82
+ task :config, :roles => :dom0 do
83
+ deprec2.push_configs(:xen, SYSTEM_CONFIG_FILES[:xen])
84
+ end
85
+
86
+ # Create new virtual machine
87
+ # xen-create-image --force --ip=192.168.1.31 --hostname=x1 --mac=00:16:3E:11:12:31
88
+
89
+ # Start a virtual image (and open console to it)
90
+ # xm create -c /etc/xen/x1.cfg
91
+
92
+ desc "Start Xen"
93
+ task :start, :roles => :dom0 do
94
+ send(run_method, "/etc/init.d/xend start")
95
+ end
96
+
97
+ desc "Stop Xen"
98
+ task :stop, :roles => :dom0 do
99
+ send(run_method, "/etc/init.d/xend stop")
100
+ end
101
+
102
+ desc "Restart Xen"
103
+ task :restart, :roles => :dom0 do
104
+ send(run_method, "/etc/init.d/xend restart")
105
+ end
106
+
107
+ desc "Reload Xen"
108
+ task :reload, :roles => :dom0 do
109
+ send(run_method, "/etc/init.d/xend reload")
110
+ end
111
+
112
+ task :list, :roles => :dom0 do
113
+ sudo "xm list"
114
+ end
115
+
116
+ task :info, :roles => :dom0 do
117
+ sudo "xm info"
118
+ end
119
+
120
+ desc "Migrate a slice on one Xen host to another. Slice is stopped, disk is tar'd up and transferred to new host."
121
+ task :migrate do
122
+
123
+ # Get user input for these values
124
+ xen_old_host && xen_new_host && xen_disk_size && xen_swap_size && xen_slice
125
+
126
+ # copy_disk
127
+ copy_slice_config
128
+ create_lvm_disks
129
+ build_slice_from_tarball
130
+ end
131
+
132
+ task :copy_disk do
133
+ mnt_dir = "/mnt/#{xen_slice}-disk"
134
+ tarball = "/tmp/#{xen_slice}-disk.tar"
135
+ lvm_disk = "/dev/vm_local/#{xen_slice}-disk"
136
+
137
+ # Shutdown slice
138
+ sudo "xm list | grep #{xen_slice} && #{sudo} xm shutdown #{xen_slice} && sleep 10; exit 0", :hosts => xen_old_host
139
+
140
+ # Tar up disk partition
141
+ sudo "test -d #{mnt_dir} || #{sudo} mkdir #{mnt_dir}; exit 0", :hosts => xen_old_host
142
+ sudo "mount | grep #{mnt_dir} || #{sudo} mount -t auto #{lvm_disk} #{mnt_dir}; exit 0", :hosts => xen_old_host
143
+ sudo "sh -c 'cd #{mnt_dir} && tar cfp #{tarball} *'", :hosts => xen_old_host
144
+ sudo "umount #{mnt_dir}", :hosts => xen_old_host
145
+ sudo "rmdir #{mnt_dir}", :hosts => xen_old_host
146
+
147
+ # start slice again if necessary
148
+ # xm create ${SLICE}.cfg
149
+
150
+ # copy to other server
151
+ run "scp #{tarball} #{xen_new_host}:/tmp/", :hosts => xen_old_host
152
+
153
+ # clean up tarball
154
+ sudo "rm #{tarball}", :hosts => xen_old_host
155
+ end
156
+
157
+ task :copy_slice_config do
158
+ run "scp /etc/xen/#{xen_slice}.cfg #{xen_new_host}:", :hosts => xen_old_host
159
+ sudo "test -f /etc/xen/#{xen_slice}.cfg || #{sudo} mv #{xen_slice}.cfg /etc/xen/", :hosts => xen_new_host
160
+ end
161
+
162
+ task :create_lvm_disks do
163
+ xen_new_host
164
+ # create lvm disks on new host
165
+ disks = {"#{xen_slice}-disk" => xen_disk_size, "#{xen_slice}-swap" => xen_swap_size}
166
+ disks.each { |disk, size|
167
+ puts "Creating #{disk} (#{size} GB)"
168
+ sudo "lvcreate -L #{size}G -n #{disk} vm_local", :hosts => xen_new_host
169
+ sudo "mkfs.ext3 /dev/vm_local/#{disk}", :hosts => xen_new_host
170
+ }
171
+ end
172
+
173
+ task :build_slice_from_tarball do
174
+ mnt_dir = "/mnt/#{xen_slice}-disk"
175
+ tarball = "/tmp/#{xen_slice}-disk.tar"
176
+ lvm_disk = "/dev/vm_local/#{xen_slice}-disk"
177
+
178
+ # untar archive into lvm disk
179
+ sudo "test -d #{mnt_dir} || #{sudo} mkdir #{mnt_dir}; exit 0", :hosts => xen_new_host
180
+ sudo "mount | grep #{mnt_dir} || #{sudo} mount -t auto #{lvm_disk} #{mnt_dir}; exit 0", :hosts => xen_new_host
181
+ sudo "sh -c 'cd #{mnt_dir} && tar xf #{tarball}'", :hosts => xen_new_host
182
+ sudo "umount #{mnt_dir}", :hosts => xen_new_host
183
+ sudo "rmdir #{mnt_dir}", :hosts => xen_new_host
184
+ end
185
+
186
+ desc "Enable hardy heron domU's on gutsy dom0. (Note required on hardy)"
187
+ task :enable_hardy_domu, :roles => :dom0 do
188
+ # Note, hardy keeps debootrap in /usr/share/debootstrap/scripts/
189
+ # create debootstrap symlink
190
+ sudo "ln -sf /usr/lib/debootstrap/scripts/gutsy /usr/lib/debootstrap/scripts/hardy"
191
+ # link xen-tools hooks
192
+ sudo "ln -sf /usr/lib/xen-tools/edgy.d /usr/lib/xen-tools/hardy.d"
193
+ end
194
+
195
+ task :touch_hwclock do
196
+ sudo "touch /etc/init.d/hwclock.sh"
197
+ end
198
+
199
+ end
200
+
201
+ end
202
+ end
203
+
204
+
205
+ # Stop the 'incrementing ethX problem'
206
+ #
207
+ # Ubuntu stores the MAC addresses of the NICs it sees. If you change an ethernet card (real or virtual)
208
+ # it will assign is a new ethX address. That's why you'll sometimes find eth2 but no eth1.
209
+ # Your domU's should have a MAC address assigned in their config file but if you come across this problem,
210
+ # fix it with this:
211
+ #
212
+ # sudo rm /etc/udev/rules.d/70-persistent-net.rules
213
+
214
+
215
+
216
+ # ubuntu bugs
217
+ #
218
+ # check if they're fixed in hardy heron
219
+
220
+ # 1: domains are not shut down on system shutdown
221
+ # cause: order that init scripts get called
222
+ # fix: call /etc/init.d/xendomains from /etc/init.d/xend script
223
+
224
+ # stop)
225
+ # /etc/init.d/xendomains stop # make sure domains are shut down
226
+ # xend stop
227
+ # ;;
228
+
229
+ #
230
+ # Install xen on ubuntu hardy
231
+ #
232
+ # ref: http://www.howtoforge.com/ubuntu-8.04-server-install-xen-from-ubuntu-repositories
233
+ #
234
+
235
+ # Install Xen packages
236
+ # apt-get install ubuntu-xen-server
237
+ #
238
+ # Installs these:
239
+ #
240
+ # binutils binutils-static bridge-utils debootstrap libasound2 libconfig-inifiles-perl libcurl3 libdirectfb-1.0-0 libsdl1.2debian
241
+ # libsdl1.2debian-alsa libtext-template-perl libxen3 libxml2 linux-image-2.6.24-16-xen linux-image-xen
242
+ # linux-restricted-modules-2.6.24-16-xen linux-restricted-modules-common linux-restricted-modules-xen
243
+ # linux-ubuntu-modules-2.6.24-16-xen linux-xen nvidia-kernel-common python-dev python-xen-3.2 python2.5-dev ubuntu-xen-server
244
+ # xen-docs-3.2 xen-hypervisor-3.2 xen-tools xen-utils-3.2
245
+
246
+ # before/after 'uname -a'
247
+ #
248
+ # Linux bb 2.6.24-16-server #1 SMP Thu Apr 10 13:15:38 UTC 2008 x86_64 GNU/Linux
249
+ # Linux bb 2.6.24-16-xen #1 SMP Thu Apr 10 14:35:03 UTC 2008 x86_64 GNU/Linux
250
+ #
251
+ # Stop apparmor # XXX investigate why
252
+ # /etc/init.d/apparmor stop
253
+ # update-rc.d -f apparmor remove
254
+
255
+ # mkdir /home/xen
256
+
257
+ # edit /etc/xen-tools/xen-tools.cfg
258
+
259
+ # create image with xen-tools
260
+ # xen-create-image --hostname=x1 --size=2Gb --swap=256Mb --ide --ip=192.168.1.51 --memory=256Mb --install-method=debootstrap --dist=hardy
261
+
262
+ # update /etc/xen/<domain>.cfg
263
+ #
264
+ # disk = [
265
+ # 'tap:aio:/home/xen/domains/xen1.example.com/swap.img,hda1,w',
266
+ # 'tap:aio:/home/xen/domains/xen1.example.com/disk.img,hda2,w',
267
+ # ]