le1t0-deprec 2.1.6.001

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. data/CHANGELOG +444 -0
  2. data/COPYING +19 -0
  3. data/LICENSE +339 -0
  4. data/README +154 -0
  5. data/THANKS +17 -0
  6. data/bin/depify +139 -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/deprec-1.x/deprec-1.x.quickstart +50 -0
  12. data/docs/deprec-1.x/notes.txt +12 -0
  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 +42 -0
  19. data/lib/deprec/capistrano_extensions.rb +446 -0
  20. data/lib/deprec/recipes.rb +7 -0
  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 +190 -0
  24. data/lib/deprec/recipes/ar_sendmail.rb +67 -0
  25. data/lib/deprec/recipes/aspell.rb +22 -0
  26. data/lib/deprec/recipes/canonical.rb +68 -0
  27. data/lib/deprec/recipes/cap.rb +39 -0
  28. data/lib/deprec/recipes/chef.rb +68 -0
  29. data/lib/deprec/recipes/collectd.rb +112 -0
  30. data/lib/deprec/recipes/db/couchdb.rb +107 -0
  31. data/lib/deprec/recipes/db/mysql.rb +194 -0
  32. data/lib/deprec/recipes/db/postgresql.rb +104 -0
  33. data/lib/deprec/recipes/db/sqlite.rb +37 -0
  34. data/lib/deprec/recipes/ddclient.rb +51 -0
  35. data/lib/deprec/recipes/deprec.rb +167 -0
  36. data/lib/deprec/recipes/deprecated.rb +71 -0
  37. data/lib/deprec/recipes/drbd.rb +137 -0
  38. data/lib/deprec/recipes/dummy.rb +22 -0
  39. data/lib/deprec/recipes/example.rb +115 -0
  40. data/lib/deprec/recipes/git.rb +97 -0
  41. data/lib/deprec/recipes/gitosis.rb.disabled +55 -0
  42. data/lib/deprec/recipes/glusterfs.rb +176 -0
  43. data/lib/deprec/recipes/god.rb +70 -0
  44. data/lib/deprec/recipes/haproxy.rb +115 -0
  45. data/lib/deprec/recipes/heartbeat.rb +138 -0
  46. data/lib/deprec/recipes/imagemagick/imagemagick_bin.rb +24 -0
  47. data/lib/deprec/recipes/imagemagick/imagemagick_src.rb +39 -0
  48. data/lib/deprec/recipes/integrity.rb +108 -0
  49. data/lib/deprec/recipes/iptables.rb +94 -0
  50. data/lib/deprec/recipes/java.rb +23 -0
  51. data/lib/deprec/recipes/keepalived.rb +78 -0
  52. data/lib/deprec/recipes/ldap.rb +52 -0
  53. data/lib/deprec/recipes/logrotate.rb +56 -0
  54. data/lib/deprec/recipes/lvm.rb +20 -0
  55. data/lib/deprec/recipes/memcache.rb +49 -0
  56. data/lib/deprec/recipes/mongodb.rb +94 -0
  57. data/lib/deprec/recipes/monit.rb +135 -0
  58. data/lib/deprec/recipes/mysql_proxy.rb +67 -0
  59. data/lib/deprec/recipes/nagios.rb +361 -0
  60. data/lib/deprec/recipes/network.rb +116 -0
  61. data/lib/deprec/recipes/ntp.rb +103 -0
  62. data/lib/deprec/recipes/php.rb +58 -0
  63. data/lib/deprec/recipes/postfix.rb +115 -0
  64. data/lib/deprec/recipes/profiles.rb +125 -0
  65. data/lib/deprec/recipes/raid/amcc_3ware.rb +21 -0
  66. data/lib/deprec/recipes/rails.rb +330 -0
  67. data/lib/deprec/recipes/redhat_cluster.rb +228 -0
  68. data/lib/deprec/recipes/redis.rb +90 -0
  69. data/lib/deprec/recipes/ruby/mri.rb +55 -0
  70. data/lib/deprec/recipes/ruby/ree.rb +40 -0
  71. data/lib/deprec/recipes/rvm.rb +32 -0
  72. data/lib/deprec/recipes/s3utils.rb +63 -0
  73. data/lib/deprec/recipes/sphinx/thinking_sphinx.rb +105 -0
  74. data/lib/deprec/recipes/sphinx/ultrasphinx.rb +86 -0
  75. data/lib/deprec/recipes/ssh.rb +147 -0
  76. data/lib/deprec/recipes/ssl.rb +56 -0
  77. data/lib/deprec/recipes/starling.rb +119 -0
  78. data/lib/deprec/recipes/svn.rb +171 -0
  79. data/lib/deprec/recipes/syslog.rb +63 -0
  80. data/lib/deprec/recipes/trac.rb.disabled +277 -0
  81. data/lib/deprec/recipes/tsung.rb +74 -0
  82. data/lib/deprec/recipes/ubuntu.rb +90 -0
  83. data/lib/deprec/recipes/users.rb +90 -0
  84. data/lib/deprec/recipes/utils.rb +58 -0
  85. data/lib/deprec/recipes/vnstat.rb +85 -0
  86. data/lib/deprec/recipes/web/apache.rb +143 -0
  87. data/lib/deprec/recipes/web/nginx.rb +172 -0
  88. data/lib/deprec/recipes/wordpress.rb.notworking +96 -0
  89. data/lib/deprec/recipes/wpmu.rb +103 -0
  90. data/lib/deprec/recipes/xen.rb +364 -0
  91. data/lib/deprec/recipes/xentools.rb +101 -0
  92. data/lib/deprec/recipes_minus_rails.rb +125 -0
  93. data/lib/deprec/templates/aoe/aoe-init +55 -0
  94. data/lib/deprec/templates/aoe/fence_aoemask +351 -0
  95. data/lib/deprec/templates/apache/namevirtualhosts.conf +5 -0
  96. data/lib/deprec/templates/apache/ports.conf.erb +5 -0
  97. data/lib/deprec/templates/apache/status.conf.erb +17 -0
  98. data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +9 -0
  99. data/lib/deprec/templates/ar_sendmail/monit.conf.erb +5 -0
  100. data/lib/deprec/templates/chef/chef.json.erb +1 -0
  101. data/lib/deprec/templates/chef/solo.rb +2 -0
  102. data/lib/deprec/templates/collectd/collectd-init.d +153 -0
  103. data/lib/deprec/templates/collectd/collectd.conf.erb +686 -0
  104. data/lib/deprec/templates/ddclient/ddclient.conf.erb +11 -0
  105. data/lib/deprec/templates/ddclient/ddclient.erb +15 -0
  106. data/lib/deprec/templates/deprec/caprc.erb +14 -0
  107. data/lib/deprec/templates/drbd/drbd.conf.erb +531 -0
  108. data/lib/deprec/templates/glusterfs/glusterfsd-init.erb +95 -0
  109. data/lib/deprec/templates/gnbd_client/cluster.conf.erb +21 -0
  110. data/lib/deprec/templates/gnbd_client/clvm-default.erb +3 -0
  111. data/lib/deprec/templates/gnbd_client/cman-default.erb +6 -0
  112. data/lib/deprec/templates/gnbd_client/gnbdimports.conf.erb +1 -0
  113. data/lib/deprec/templates/gnbd_server/cluster.conf.erb +20 -0
  114. data/lib/deprec/templates/gnbd_server/clvm-default.erb +3 -0
  115. data/lib/deprec/templates/gnbd_server/cman-default.erb +6 -0
  116. data/lib/deprec/templates/gnbd_server/gnbd-server-default.erb +1 -0
  117. data/lib/deprec/templates/gnbd_server/gnbdexports.conf.erb +1 -0
  118. data/lib/deprec/templates/god/god-conf.erb +2 -0
  119. data/lib/deprec/templates/god/god-init.erb +47 -0
  120. data/lib/deprec/templates/haproxy/haproxy-init.d +120 -0
  121. data/lib/deprec/templates/haproxy/haproxy.cfg.erb +31 -0
  122. data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
  123. data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
  124. data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
  125. data/lib/deprec/templates/integrity/apache_vhost.erb +4 -0
  126. data/lib/deprec/templates/integrity/config.ru.erb +21 -0
  127. data/lib/deprec/templates/integrity/config.yml.erb +43 -0
  128. data/lib/deprec/templates/iptables/firewall-default.erb +13 -0
  129. data/lib/deprec/templates/iptables/firewall-init.erb +171 -0
  130. data/lib/deprec/templates/keepalived/keepalived.conf.erb +18 -0
  131. data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
  132. data/lib/deprec/templates/mongodb/mongodb-init.d +88 -0
  133. data/lib/deprec/templates/mongrel/apache_vhost.conf.erb +148 -0
  134. data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
  135. data/lib/deprec/templates/mongrel/mongrel_cluster-init-script +54 -0
  136. data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
  137. data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
  138. data/lib/deprec/templates/mongrel/nginx_vhost.conf.erb +41 -0
  139. data/lib/deprec/templates/monit/monit-init-script +104 -0
  140. data/lib/deprec/templates/monit/monitrc.erb +250 -0
  141. data/lib/deprec/templates/monit/nothing.monitrc +0 -0
  142. data/lib/deprec/templates/mysql/create_databases.sql +20 -0
  143. data/lib/deprec/templates/mysql/database.yml.prod +6 -0
  144. data/lib/deprec/templates/mysql/database.yml.stage +6 -0
  145. data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
  146. data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
  147. data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
  148. data/lib/deprec/templates/mysql_proxy/mysql-proxy-default.erb +4 -0
  149. data/lib/deprec/templates/nagios/README +32 -0
  150. data/lib/deprec/templates/nagios/cgi.cfg.erb +357 -0
  151. data/lib/deprec/templates/nagios/check_linux_free_memory.pl +118 -0
  152. data/lib/deprec/templates/nagios/check_mongrel_cluster.rb +82 -0
  153. data/lib/deprec/templates/nagios/htpasswd.users +1 -0
  154. data/lib/deprec/templates/nagios/mrtg.cfg +180 -0
  155. data/lib/deprec/templates/nagios/nagios.cfg.erb +1325 -0
  156. data/lib/deprec/templates/nagios/nrpe.cfg.erb +222 -0
  157. data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
  158. data/lib/deprec/templates/nagios/objects/commands.cfg.erb +265 -0
  159. data/lib/deprec/templates/nagios/objects/contacts.cfg.erb +89 -0
  160. data/lib/deprec/templates/nagios/objects/hosts.cfg.erb +114 -0
  161. data/lib/deprec/templates/nagios/objects/localhost.cfg.erb +116 -0
  162. data/lib/deprec/templates/nagios/objects/services.cfg.erb +165 -0
  163. data/lib/deprec/templates/nagios/objects/timeperiods.cfg.erb +94 -0
  164. data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
  165. data/lib/deprec/templates/network/hostname.erb +1 -0
  166. data/lib/deprec/templates/network/hosts.erb +2 -0
  167. data/lib/deprec/templates/network/interfaces.erb +18 -0
  168. data/lib/deprec/templates/network/resolv.conf.erb +6 -0
  169. data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
  170. data/lib/deprec/templates/nginx/mime.types.erb +70 -0
  171. data/lib/deprec/templates/nginx/nginx-init-script +62 -0
  172. data/lib/deprec/templates/nginx/nginx.conf.erb +125 -0
  173. data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
  174. data/lib/deprec/templates/nginx/nothing.conf +1 -0
  175. data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +41 -0
  176. data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
  177. data/lib/deprec/templates/passenger/apache_vhost.erb +29 -0
  178. data/lib/deprec/templates/passenger/logrotate.conf.erb +12 -0
  179. data/lib/deprec/templates/passenger/passenger.conf.erb +21 -0
  180. data/lib/deprec/templates/passenger/passenger.load.erb +3 -0
  181. data/lib/deprec/templates/postfix/aliases.erb +3 -0
  182. data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
  183. data/lib/deprec/templates/postfix/main.cf.erb +36 -0
  184. data/lib/deprec/templates/postfix/master.cf.erb +77 -0
  185. data/lib/deprec/templates/redis/redis-conf.erb +132 -0
  186. data/lib/deprec/templates/redis/redis-init.erb +50 -0
  187. data/lib/deprec/templates/s3utils/s3cfg +35 -0
  188. data/lib/deprec/templates/s3utils/s3config.yml +3 -0
  189. data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
  190. data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
  191. data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
  192. data/lib/deprec/templates/ssl/make-ssl-cert +138 -0
  193. data/lib/deprec/templates/ssl/ssl-cert-snakeoil.key +15 -0
  194. data/lib/deprec/templates/ssl/ssl-cert-snakeoil.pem +19 -0
  195. data/lib/deprec/templates/starling/monit.conf.erb +14 -0
  196. data/lib/deprec/templates/starling/starling-init-script.erb +71 -0
  197. data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
  198. data/lib/deprec/templates/syslog/syslog.conf.erb +71 -0
  199. data/lib/deprec/templates/syslog/syslogd.erb +13 -0
  200. data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
  201. data/lib/deprec/templates/trac/nginx_vhost.conf.erb +26 -0
  202. data/lib/deprec/templates/trac/trac.ini.erb +169 -0
  203. data/lib/deprec/templates/trac/trac_deprec.png +0 -0
  204. data/lib/deprec/templates/trac/tracd-init.erb +43 -0
  205. data/lib/deprec/templates/trac/users.htdigest.erb +0 -0
  206. data/lib/deprec/templates/tsung/tsung.xml.erb +47 -0
  207. data/lib/deprec/templates/vnstat/config.php +57 -0
  208. data/lib/deprec/templates/wordpress/apache2_wordpress_vhost.conf.erb +31 -0
  209. data/lib/deprec/templates/wordpress/wp-config.php.erb +31 -0
  210. data/lib/deprec/templates/wpmu/apache_vhost.conf.erb +13 -0
  211. data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
  212. data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
  213. data/lib/deprec/templates/xen/xend-init.erb +57 -0
  214. data/lib/deprec/templates/xen/xendomains.erb +137 -0
  215. data/lib/deprec/templates/xentools/100-ubuntu-setup +26 -0
  216. data/lib/deprec/templates/xentools/15-disable-hwclock +40 -0
  217. data/lib/deprec/templates/xentools/30-disable-gettys +57 -0
  218. data/lib/deprec/templates/xentools/31-ubuntu-setup +32 -0
  219. data/lib/deprec/templates/xentools/40-setup-networking +145 -0
  220. data/lib/deprec/templates/xentools/98-custom +17 -0
  221. data/lib/deprec/templates/xentools/xen-tools.conf.erb +278 -0
  222. data/lib/deprec/templates/xentools/xm.tmpl.erb +138 -0
  223. data/lib/deprec_cmd_completion.sh +26 -0
  224. data/lib/deprec_minus_rails.rb +12 -0
  225. data/lib/vmbuilder_plugins/all.rb +20 -0
  226. data/lib/vmbuilder_plugins/apt.rb +93 -0
  227. data/lib/vmbuilder_plugins/emerge.rb +76 -0
  228. data/lib/vmbuilder_plugins/gem.rb +100 -0
  229. data/lib/vmbuilder_plugins/std.rb +203 -0
  230. metadata +304 -0
@@ -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
+ default :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,364 @@
1
+ def handle_xen_images(&block)
2
+ do_xen_images = (ENV['ONLY'] || '').split(',')
3
+ xen_images.each do |xen_image|
4
+ next if do_xen_images.size > 0 && !do_xen_images.include?(xen_image[:hostname])
5
+ yield(xen_image)
6
+ end
7
+ end
8
+
9
+ # Copyright 2006-2010 by Mike Bailey, le1t0@github. All rights reserved.
10
+ Capistrano::Configuration.instance(:must_exist).load do
11
+ namespace :deprec do
12
+ namespace :xen do
13
+
14
+ # define images to create, i.e.:
15
+ # set :xen_images, [
16
+ # {
17
+ # :lvm => 'mylvm',
18
+ # :gateway => '10.0.0.1',
19
+ # :netmask => '255.255.0.0',
20
+ # :size => '15Gb',
21
+ # :memory => '1Gb',
22
+ # :swap => '2Gb',
23
+ # :hostname => 'rails1',
24
+ # :ip => '10.0.2.1',
25
+ # :mac => '00:16:3e:00:00:01'
26
+ # } ]
27
+ set :xen_images, []
28
+
29
+ set :xen_volume_group_name, 'xendisks'
30
+ # Config variables for migration
31
+ default(:xen_slice) { Capistrano::CLI.ui.ask("Slice name") }
32
+ default(:xen_old_host) { Capistrano::CLI.ui.ask("Old Xen host") }
33
+ default(:xen_new_host) { Capistrano::CLI.ui.ask("New Xen host") }
34
+ set(:xen_disk_size) { Capistrano::CLI.ui.ask("Disk size (GB)") }
35
+ set(:xen_swap_size) { Capistrano::CLI.ui.ask("Swap size (GB)") }
36
+
37
+ # ref: http://www.eadz.co.nz/blog/article/xen-gutsy.html
38
+
39
+ desc "Install Xen"
40
+ task :install, :roles => :dom0 do
41
+ install_deps
42
+ top.deprec.xentools.install
43
+ disable_apparmour
44
+ # enable_hardy_domu Should only be run on gutsy
45
+ initial_config
46
+ end
47
+
48
+ task :install_deps, :roles => :dom0 do
49
+ # for amd64 version of ubuntu 7.10
50
+ # 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 )
51
+ # alternatively, for x86 version of ubuntu:
52
+ # apt-get install ubuntu-xen-server libc6-xen lvm2
53
+ # apt.install( {:base => %w(ubuntu-xen-server libc6-xen lvm2)}, :stable )
54
+ apt.install( {:base => %w(ubuntu-xen-server lvm2)}, :stable )
55
+
56
+ end
57
+
58
+ task :disable_apparmour, :roles => :dom0 do
59
+ sudo '/etc/init.d/apparmor stop'
60
+ sudo 'update-rc.d -f apparmor remove'
61
+ end
62
+
63
+ # task :disable_tls, :roles => :dom0 do
64
+ # sudo 'mv /lib/tls /lib/tls.disabled'
65
+ # end
66
+
67
+ SYSTEM_CONFIG_FILES[:xen] = [
68
+
69
+ # {:template => "xend-config.sxp.erb",
70
+ # :path => '/etc/xen/xend-config.sxp',
71
+ # :mode => 0644,
72
+ # :owner => 'root:root'},
73
+ #
74
+ # {:template => "xendomains.erb",
75
+ # :path => '/etc/default/xendomains',
76
+ # :mode => 0755,
77
+ # :owner => 'root:root'},
78
+ #
79
+ # This gives you a second network bridge on second ethernet device
80
+ {:template => "network-bridge-wrapper",
81
+ :path => '/etc/xen/scripts/network-bridge-wrapper',
82
+ :mode => 0755,
83
+ :owner => 'root:root'},
84
+ #
85
+ # # Bugfix for gutsy - xendomains fails to shut down domains on system shutdown
86
+ # {:template => "xend-init.erb",
87
+ # :path => '/etc/init.d/xend',
88
+ # :mode => 0755,
89
+ # :owner => 'root:root'}
90
+
91
+ ]
92
+
93
+ desc "Push Xen config files to server"
94
+ task :initial_config, :roles => :dom0 do
95
+ # Non-standard! We're pushing these straight out
96
+ SYSTEM_CONFIG_FILES[:xen].each do |file|
97
+ deprec2.render_template(:xen, file.merge(:remote => true))
98
+ end
99
+ end
100
+
101
+ desc "Generate configuration file(s) for Xen from template(s)"
102
+ task :config_gen do
103
+ SYSTEM_CONFIG_FILES[:xen].each do |file|
104
+ deprec2.render_template(:xen, file)
105
+ end
106
+ end
107
+
108
+ desc "Push Xen config files to server"
109
+ task :config, :roles => :dom0 do
110
+ deprec2.push_configs(:xen, SYSTEM_CONFIG_FILES[:xen])
111
+ end
112
+
113
+ # Create new virtual machine
114
+ # xen-create-image --force --ip=192.168.1.31 --hostname=x1 --mac=00:16:3E:11:12:31
115
+
116
+ # Start a virtual image (and open console to it)
117
+ # xm create /etc/xen/x1.cfg -c
118
+
119
+ desc "Start Xen"
120
+ task :start, :roles => :dom0 do
121
+ send(run_method, "/etc/init.d/xend start")
122
+ end
123
+
124
+ desc "Stop Xen"
125
+ task :stop, :roles => :dom0 do
126
+ send(run_method, "/etc/init.d/xend stop")
127
+ end
128
+
129
+ desc "Restart Xen"
130
+ task :restart, :roles => :dom0 do
131
+ send(run_method, "/etc/init.d/xend restart")
132
+ end
133
+
134
+ desc "Reload Xen"
135
+ task :reload, :roles => :dom0 do
136
+ send(run_method, "/etc/init.d/xend reload")
137
+ end
138
+
139
+ task :list, :roles => :dom0 do
140
+ sudo "xm list"
141
+ end
142
+
143
+ task :info, :roles => :dom0 do
144
+ sudo "xm info"
145
+ end
146
+
147
+ desc "Migrate a slice on one Xen host to another. Slice is stopped, disk is tar'd up and transferred to new host."
148
+ task :migrate do
149
+
150
+ # Get user input for these values
151
+ xen_old_host && xen_new_host && xen_disk_size && xen_swap_size && xen_slice
152
+
153
+ copy_disk
154
+ copy_slice_config
155
+ create_lvm_disks
156
+ build_slice_from_tarball
157
+ end
158
+
159
+ task :copy_disk do
160
+ mnt_dir = "/mnt/#{xen_slice}-disk"
161
+ tarball = "/tmp/#{xen_slice}-disk.tar"
162
+ lvm_disk = "/dev/#{xen_volume_group_name}/#{xen_slice}-disk"
163
+
164
+ # Shutdown slice
165
+ sudo "xm list | grep #{xen_slice} && #{sudo} xm shutdown #{xen_slice} && sleep 10; exit 0", :hosts => xen_old_host
166
+
167
+ # Tar up disk partition
168
+ sudo "test -d #{mnt_dir} || #{sudo} mkdir #{mnt_dir}; exit 0", :hosts => xen_old_host
169
+ sudo "mount | grep #{mnt_dir} || #{sudo} mount -t auto #{lvm_disk} #{mnt_dir}; exit 0", :hosts => xen_old_host
170
+ sudo "sh -c 'cd #{mnt_dir} && tar cfp #{tarball} *'", :hosts => xen_old_host
171
+ sudo "umount #{mnt_dir}", :hosts => xen_old_host
172
+ sudo "rmdir #{mnt_dir}", :hosts => xen_old_host
173
+
174
+ # start slice again if necessary
175
+ # xm create ${SLICE}.cfg
176
+
177
+ # copy to other server
178
+ run "scp #{tarball} #{xen_new_host}:/tmp/", :hosts => xen_old_host
179
+
180
+ # clean up tarball
181
+ sudo "rm #{tarball}", :hosts => xen_old_host
182
+ end
183
+
184
+ task :copy_slice_config do
185
+ run "scp /etc/xen/#{xen_slice}.cfg #{xen_new_host}:", :hosts => xen_old_host
186
+ sudo "test -f /etc/xen/#{xen_slice}.cfg || #{sudo} mv #{xen_slice}.cfg /etc/xen/", :hosts => xen_new_host
187
+ end
188
+
189
+ task :create_lvm_disks do
190
+ xen_new_host
191
+ # create lvm disks on new host
192
+ disks = {"#{xen_slice}-disk" => xen_disk_size, "#{xen_slice}-swap" => xen_swap_size}
193
+ disks.each { |disk, size|
194
+ puts "Creating #{disk} (#{size} GB)"
195
+ sudo "lvcreate -L #{size}G -n #{disk} #{xen_volume_group_name}", :hosts => xen_new_host
196
+ sudo "mkfs.ext3 /dev/#{xen_volume_group_name}/#{disk}", :hosts => xen_new_host
197
+ }
198
+ end
199
+
200
+ task :build_slice_from_tarball do
201
+ mnt_dir = "/mnt/#{xen_slice}-disk"
202
+ tarball = "/tmp/#{xen_slice}-disk.tar"
203
+ lvm_disk = "/dev/#{xen_volume_group_name}/#{xen_slice}-disk"
204
+
205
+ # untar archive into lvm disk
206
+ sudo "test -d #{mnt_dir} || #{sudo} mkdir #{mnt_dir}; exit 0", :hosts => xen_new_host
207
+ sudo "mount | grep #{mnt_dir} || #{sudo} mount -t auto #{lvm_disk} #{mnt_dir}; exit 0", :hosts => xen_new_host
208
+ sudo "sh -c 'cd #{mnt_dir} && tar xf #{tarball}'", :hosts => xen_new_host
209
+ sudo "umount #{mnt_dir}", :hosts => xen_new_host
210
+ sudo "rmdir #{mnt_dir}", :hosts => xen_new_host
211
+ end
212
+
213
+ desc "Enable hardy heron domU's on gutsy dom0. (Note required on hardy)"
214
+ task :enable_hardy_domu, :roles => :dom0 do
215
+ # Note, hardy keeps debootrap in /usr/share/debootstrap/scripts/
216
+ # create debootstrap symlink
217
+ sudo "ln -sf /usr/lib/debootstrap/scripts/gutsy /usr/lib/debootstrap/scripts/hardy"
218
+ # link xen-tools hooks
219
+ sudo "ln -sf /usr/lib/xen-tools/edgy.d /usr/lib/xen-tools/hardy.d"
220
+ end
221
+
222
+ task :touch_hwclock do
223
+ sudo "touch /etc/init.d/hwclock.sh"
224
+ end
225
+
226
+ desc "Create Xen images"
227
+ task :create_images, :roles => :dom0 do
228
+ handle_xen_images do |xen_image|
229
+ args = []
230
+ vcpus = xen_image.delete(:vcpus)
231
+ cpus = xen_image.delete(:cpus)
232
+ xen_image.each do |k,v|
233
+ args << "--#{k}='#{v}'"
234
+ end
235
+ cmd = "sh -c \"[ -e /etc/xen/#{xen_image[:hostname]}.cfg ] || /usr/bin/xen-create-image #{args.join(' ')}\""
236
+ sudo cmd
237
+ deprec2.append_to_file_if_missing("/etc/xen/#{xen_image[:hostname]}.cfg", "vcpus = '#{vcpus}'") unless vcpus.nil?
238
+ deprec2.append_to_file_if_missing("/etc/xen/#{xen_image[:hostname]}.cfg", "cpus = '#{cpus}'") unless cpus.nil?
239
+ end
240
+ top.deprec.xen.auto_start_images
241
+ end
242
+
243
+ desc "Make links for xen image configs to be started automatically"
244
+ task :auto_start_images, :roles => :dom0 do
245
+ handle_xen_images do |xen_image|
246
+ cmd = "sh -c \"ln -nsf /etc/xen/#{xen_image[:hostname]}.cfg /etc/xen/auto/#{xen_image[:hostname]}.cfg\""
247
+ sudo cmd
248
+ end
249
+ end
250
+
251
+ desc "Make links for xen image configs to be started automatically"
252
+ task :undo_auto_start_images, :roles => :dom0 do
253
+ handle_xen_images do |xen_image|
254
+ cmd = "sh -c \"rm -f /etc/xen/auto/#{xen_image[:hostname]}.cfg\""
255
+ sudo cmd
256
+ end
257
+ end
258
+
259
+ desc "Start Xen images"
260
+ task :start_images, :roles => :dom0 do
261
+ handle_xen_images do |xen_image|
262
+ cmd = "sh -c '/usr/sbin/xm create #{xen_image[:hostname]}.cfg 1>/dev/null ; true'"
263
+ sudo cmd
264
+ end
265
+ end
266
+
267
+ desc "Show configs of all installed VMs"
268
+ task :show_vm_configs do
269
+ all_data = ""
270
+ sudo "grep -v '^$' /etc/xen/*.cfg | awk -v h=$(hostname) '{ print h\":\"$0; }'" do |channel, stream, data|
271
+ all_data += data.strip
272
+ end
273
+ datalines = all_data.split("\n")
274
+ datahashes = datalines.collect { |line| a = line.split(":", 3) ; { :host => a[0], :vm => a[1].gsub(/^\/etc\/xen\//, '').gsub(/\.cfg$/, ''), :line => a[2] } }
275
+ datahashes2 = {}
276
+ datahashes.each do |dh|
277
+ datahashes2[dh[:host]] ||= {}
278
+ datahashes2[dh[:host]][dh[:vm]] ||= ""
279
+ datahashes2[dh[:host]][dh[:vm]] << dh[:line] + "\n" unless dh[:line] =~ /^(\s*|\s*#.*)$/
280
+ end
281
+ datahashes2.each do |host, vm_files|
282
+ vm_files.each do |vm, file|
283
+ puts "#{host}:#{vm}"
284
+ puts file.gsub(/\[\s+([^\s\]]+)\s+([^\s\]]+)\s+\]/, '[\1\2]').gsub(/(^|\n)(\s*)([^\s=]+)(\s*)=(\s*)([^\s=].*[^\s=]?)(\s*)(\n|$)/, '\1\3=\6\8')
285
+ end
286
+ end
287
+ end
288
+
289
+ end
290
+
291
+ end
292
+ end
293
+
294
+ # Add support for intrepid and jaunty guests to hardy host
295
+ #
296
+ # root@x1:/usr/share/debootstrap/scripts# ln -s gutsy jaunty
297
+ # root@x1:/usr/share/debootstrap/scripts# ln -s gutsy intrepid
298
+ #
299
+ # root@x1:/usr/lib/xen-tools# ln -s edgy.d intrepid.d
300
+ # root@x1:/usr/lib/xen-tools# ln -s edgy.d jaunty.d
301
+
302
+ # Stop the 'incrementing ethX problem'
303
+ #
304
+ # Ubuntu stores the MAC addresses of the NICs it sees. If you change an ethernet card (real or virtual)
305
+ # it will assign is a new ethX address. That's why you'll sometimes find eth2 but no eth1.
306
+ # Your domU's should have a MAC address assigned in their config file but if you come across this problem,
307
+ # fix it with this:
308
+ #
309
+ # sudo rm /etc/udev/rules.d/70-persistent-net.rules
310
+
311
+
312
+
313
+ # ubuntu bugs
314
+ #
315
+ # check if they're fixed in hardy heron
316
+
317
+ # 1: domains are not shut down on system shutdown
318
+ # cause: order that init scripts get called
319
+ # fix: call /etc/init.d/xendomains from /etc/init.d/xend script
320
+
321
+ # stop)
322
+ # /etc/init.d/xendomains stop # make sure domains are shut down
323
+ # xend stop
324
+ # ;;
325
+
326
+ #
327
+ # Install xen on ubuntu hardy
328
+ #
329
+ # ref: http://www.howtoforge.com/ubuntu-8.04-server-install-xen-from-ubuntu-repositories
330
+ #
331
+
332
+ # Install Xen packages
333
+ # apt-get install ubuntu-xen-server
334
+ #
335
+ # Installs these:
336
+ #
337
+ # binutils binutils-static bridge-utils debootstrap libasound2 libconfig-inifiles-perl libcurl3 libdirectfb-1.0-0 libsdl1.2debian
338
+ # libsdl1.2debian-alsa libtext-template-perl libxen3 libxml2 linux-image-2.6.24-16-xen linux-image-xen
339
+ # linux-restricted-modules-2.6.24-16-xen linux-restricted-modules-common linux-restricted-modules-xen
340
+ # 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
341
+ # xen-docs-3.2 xen-hypervisor-3.2 xen-tools xen-utils-3.2
342
+
343
+ # before/after 'uname -a'
344
+ #
345
+ # Linux bb 2.6.24-16-server #1 SMP Thu Apr 10 13:15:38 UTC 2008 x86_64 GNU/Linux
346
+ # Linux bb 2.6.24-16-xen #1 SMP Thu Apr 10 14:35:03 UTC 2008 x86_64 GNU/Linux
347
+ #
348
+ # Stop apparmor # XXX investigate why
349
+ # /etc/init.d/apparmor stop
350
+ # update-rc.d -f apparmor remove
351
+
352
+ # mkdir /home/xen
353
+
354
+ # edit /etc/xen-tools/xen-tools.cfg
355
+
356
+ # create image with xen-tools
357
+ # xen-create-image --hostname=x1 --size=2Gb --swap=256Mb --ide --ip=192.168.1.51 --memory=256Mb --install-method=debootstrap --dist=hardy
358
+
359
+ # update /etc/xen/<domain>.cfg
360
+ #
361
+ # disk = [
362
+ # 'tap:aio:/home/xen/domains/xen1.example.com/swap.img,hda1,w',
363
+ # 'tap:aio:/home/xen/domains/xen1.example.com/disk.img,hda2,w',
364
+ # ]