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,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
@@ -0,0 +1,137 @@
1
+ # Normal way of using this, on both hosts:
2
+ # deprec:drdb:config_gen
3
+ # <adjust anything in configs>
4
+ # deprec:drbd:install <or> deprec:drbd:config
5
+ # deprec:drbd:sync <on one host!!!>
6
+ # deprec:drbd:restart
7
+
8
+ # Copyright 2009-2010 by le1t0@github. All rights reserved.
9
+ Capistrano::Configuration.instance(:must_exist).load do
10
+ namespace :deprec do
11
+ namespace :drbd do
12
+
13
+ set :drbd_usage_count, true
14
+ set :drbd_resources, [
15
+ {
16
+ :drbd_resource => 'testing',
17
+ :drbd_protocol => 'C',
18
+ :drbd_disk_size => nil,
19
+ :drbd_lvm_lv => nil,
20
+ :drbd_lvm_vg => nil,
21
+ :drbd_drbd1_hostname => 'drbd1',
22
+ :drbd_drbd1_device => '/dev/drbd0',
23
+ :drbd_drbd1_disk => '/dev/sda7',
24
+ :drbd_drbd1_address => '172.16.0.130:7788',
25
+ :drbd_drbd2_hostname => 'drbd2',
26
+ :drbd_drbd2_device => '/dev/drbd0',
27
+ :drbd_drbd2_disk => '/dev/sda7',
28
+ :drbd_drbd2_address => '172.16.0.131:7788',
29
+ :drbd_max_buffers => '2048',
30
+ :drbd_ko_count => '4',
31
+ :drbd_rate => '10M',
32
+ :drbd_al_extents => '257',
33
+ :drbd_wfc_timeout => '0',
34
+ :drbd_degr_wfc_timeout => '120',
35
+ :drbd_allow_two_primaries => true
36
+ }
37
+ ]
38
+
39
+ desc "Install drbd on server"
40
+ task :install, :roles => :storage_server do
41
+ install_deps
42
+ config
43
+ reactivate
44
+ end
45
+
46
+ task :install_deps, :roles => :storage_server do
47
+ apt.install( {:base => %w(drbd8-utils)}, :stable )
48
+ end
49
+
50
+ # The start script has a couple of config values in it.
51
+ # We may want to extract them into a config file later
52
+ # and install this script as part of the :install task.
53
+ SYSTEM_CONFIG_FILES[:drbd] = [
54
+ {:template => 'drbd.conf.erb',
55
+ :path => '/etc/drbd.conf',
56
+ :mode => 0644,
57
+ :owner => 'root:root'}
58
+ ]
59
+
60
+ desc "Generate config files for drbd"
61
+ task :config_gen do
62
+ SYSTEM_CONFIG_FILES[:drbd].each do |file|
63
+ deprec2.render_template(:drbd, file)
64
+ end
65
+ end
66
+
67
+ desc "Push drbd config files to server"
68
+ task :config, :roles => :storage_server do
69
+ deprec2.push_configs(:drbd, SYSTEM_CONFIG_FILES[:drbd])
70
+ drbd_resources.each do |drbd|
71
+ if drbd[:drbd_lvm_vg] && drbd[:drbd_lvm_lv] && drbd[:drbd_disk_size]
72
+ sudo "sh -c '{ lvcreate -L #{drbd[:drbd_disk_size]} -n #{drbd[:drbd_lvm_lv]} #{drbd[:drbd_lvm_vg]} && { echo yes ; echo yes ; } | drbdadm create-md #{drbd[:drbd_resource]} ; } || true'"
73
+ end
74
+ end
75
+ init_devices
76
+ deprec2.append_to_file_if_missing('/etc/modules', 'drbd')
77
+ sudo "modprobe drbd"
78
+ sudo "drbdadm up all"
79
+ reactivate
80
+ end
81
+
82
+ desc "Init devices for drbd. This will erase your data!"
83
+ task :init_devices, :roles => :storage_server do
84
+ drbd_resources.each do |drbd|
85
+ # check whether we get a valid gi. If not, initialize the device.
86
+ sudo "sh -c 'drbdadm get-gi #{drbd[:drbd_resource]} || { { echo yes ; echo yes ; } | drbdadm create-md #{drbd[:drbd_resource]} ; }'"
87
+ end
88
+ end
89
+
90
+ desc "Sync data from one drbd device to another. Make sure you select the right one in case of existing data!"
91
+ task :sync, :roles => :storage_server do
92
+ drbd_resources.each do |drbd|
93
+ sudo "drbdadm -- --overwrite-data-of-peer primary #{drbd[:drbd_resource]}"
94
+ end
95
+ end
96
+
97
+ task :start, :roles => :storage_server do
98
+ sudo "/etc/init.d/drbd start"
99
+ end
100
+
101
+ task :stop, :roles => :storage_server do
102
+ sudo "/etc/init.d/drbd stop"
103
+ end
104
+
105
+ task :reload, :roles => :storage_server do
106
+ sudo "drbdadm adjust all"
107
+ make_primaries
108
+ end
109
+
110
+ task :make_primaries, :roles => :storage_server do
111
+ drbd_resources.each do |drbd|
112
+ if drbd[:drbd_allow_two_primaries]
113
+ sudo "drbdadm primary #{drbd[:drbd_resource]}"
114
+ end
115
+ end
116
+ end
117
+
118
+ task :restart do
119
+ stop
120
+ start
121
+ end
122
+
123
+ task :activate, :roles => :storage_server do
124
+ sudo "update-rc.d drbd start 51 S . stop 8 0 6 ."
125
+ end
126
+
127
+ task :deactivate, :roles => :storage_server do
128
+ sudo "update-rc.d -f drbd remove"
129
+ end
130
+
131
+ task :reactivate do
132
+ deactivate
133
+ activate
134
+ end
135
+ end
136
+ end
137
+ end
@@ -0,0 +1,22 @@
1
+ # Copyright 2010 by le1t0@github. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :deprec_tools do
5
+ desc "failing task"
6
+ task :failing_task do
7
+ run "false"
8
+ end
9
+ end if ENV['DUMMY']
10
+
11
+ [ :dummy1, :dummy2, :dummy3, :dummy4, :dummy5 ].each do |ns|
12
+ namespace ns do
13
+ [ :install, :config_gen, :config, :start, :stop, :restart, :reload, :activate, :deactivate, :backup, :restore ].each do |tsk|
14
+ desc "#{tsk} #{ns}"
15
+ task tsk do
16
+ puts "#{tsk} #{ns}"
17
+ end
18
+ end
19
+ end
20
+ end if ENV['DUMMY']
21
+ end
22
+ end
@@ -0,0 +1,115 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :example do
5
+
6
+ SRC_PACKAGES[:example] = {
7
+ :filename => 'example-1.2.3.tar.gz',
8
+ :md5sum => "d050a49bd72222ec21c6bb593b3473a5d example-1.2.3.tar.gz",
9
+ :dir => 'example-1.2.3',
10
+ :url => "http://www.example.org/dist/example/example-1.2.3.tar.gz",
11
+ :unpack => "tar zxf example-1.2.3.tar.gz;",
12
+ :configure => %w(
13
+ ./configure
14
+ --enable-mods-shared=all
15
+ --enable-proxy
16
+ ;
17
+ ).reject{|arg| arg.match '#'}.join(' '),
18
+ :make => 'make;',
19
+ :install => 'make install;',
20
+ :post_install => 'install -b support/apachectl /etc/init.d/httpd;'
21
+ }
22
+
23
+ desc "Install example"
24
+ task :install, :roles => :web do
25
+ install_deps
26
+ deprec2.download_src(SRC_PACKAGES[:example], src_dir)
27
+ deprec2.install_from_src(SRC_PACKAGES[:example], src_dir)
28
+ end
29
+
30
+ task :install_deps do
31
+ apt.install( {:base => %w(build-essential zlib1g-dev)}, :stable )
32
+ end
33
+
34
+ SYSTEM_CONFIG_FILES[:example] = [
35
+
36
+ {:template => "example.conf.erb",
37
+ :path => '/etc/example/example.conf',
38
+ :mode => 0755,
39
+ :owner => 'root:root'}
40
+
41
+ ]
42
+
43
+ PROJECT_CONFIG_FILES[:example] = [
44
+
45
+ {:template => "example.conf.erb",
46
+ :path => 'conf/example.conf',
47
+ :mode => 0755,
48
+ :owner => 'root:root'}
49
+ ]
50
+
51
+
52
+ desc "Generate configuration file(s) for XXX from template(s)"
53
+ task :config_gen do
54
+ config_gen_system
55
+ config_gen_project
56
+ end
57
+
58
+ task :config_gen_system do
59
+ SYSTEM_CONFIG_FILES[:example].each do |file|
60
+ deprec2.render_template(:example, file)
61
+ end
62
+ end
63
+
64
+ task :config_gen_project do
65
+ PROJECT_CONFIG_FILES[:example].each do |file|
66
+ deprec2.render_template(:example, file)
67
+ end
68
+ end
69
+
70
+ desc 'Deploy configuration files(s) for XXX'
71
+ task :config, :roles => :web do
72
+ config_system
73
+ config_project
74
+ end
75
+
76
+ task :config_system, :roles => :web do
77
+ deprec2.push_configs(:example, SYSTEM_CONFIG_FILES[:example])
78
+ end
79
+
80
+ task :config_project, :roles => :web do
81
+ deprec2.push_configs(:example, PROJECT_CONFIG_FILES[:example])
82
+ end
83
+
84
+
85
+ task :start, :roles => :web do
86
+ send(run_method, "/etc/init.d/example reload")
87
+ end
88
+
89
+ task :stop, :roles => :web do
90
+ send(run_method, "/etc/init.d/example reload")
91
+ end
92
+
93
+ task :restart, :roles => :web do
94
+ send(run_method, "/etc/init.d/example restart")
95
+ end
96
+
97
+ task :reload, :roles => :web do
98
+ send(run_method, "/etc/init.d/example reload")
99
+ end
100
+
101
+ task :activate, :roles => :web do
102
+ end
103
+
104
+ task :deactivate, :roles => :web do
105
+ end
106
+
107
+ task :backup, :roles => :web do
108
+ end
109
+
110
+ task :restore, :roles => :web do
111
+ end
112
+
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,97 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :git do
5
+
6
+ set :git_user, 'git'
7
+ set :git_group, 'git'
8
+ set :git_port, '9418'
9
+ set :git_keys_file, '/home/git/.ssh/authorized_keys'
10
+ set :git_root, '/var/git'
11
+
12
+ SRC_PACKAGES[:git] = {
13
+ :url => "http://kernel.org/pub/software/scm/git/git-1.6.4.3.tar.gz",
14
+ :md5sum => "95381cd27ad762c645c8e07f922879ce git-1.6.4.3.tar.gz"
15
+ }
16
+
17
+ desc "Install git"
18
+ task :install do
19
+ install_deps
20
+ deprec2.download_src(SRC_PACKAGES[:git], src_dir)
21
+ deprec2.install_from_src(SRC_PACKAGES[:git], src_dir)
22
+ # create_git_root
23
+ # create_git_user
24
+ end
25
+
26
+ # install dependencies for nginx
27
+ task :install_deps do
28
+ apt.install( {:base => %w(zlib1g-dev gettext libcurl4-gnutls-dev)}, :stable )
29
+ end
30
+
31
+ # "Start git server in local directory"
32
+ task :serve do
33
+ cmd = "git-daemon --verbose --port=#{git_port} --base-path=#{Dir.pwd} --base-path-relaxed"
34
+ puts cmd
35
+ `#{cmd}`
36
+ end
37
+
38
+ desc "Create git repos for current dir"
39
+ task :init do
40
+ `git init`
41
+ create_gitignore
42
+ create_files_in_empty_dirs
43
+ `git add . && git commit -m 'initial import'`
44
+ end
45
+
46
+ task :create_gitignore do
47
+ system("echo '.DS_Store' >> .gitignore") # files sometimes created by OSX
48
+ system("echo 'log/*' >> .gitignore") if File.directory?('log')
49
+ system("echo 'tmp/**/*' >> .gitignore") if File.directory?('tmp')
50
+ end
51
+
52
+ task :create_files_in_empty_dirs do
53
+ %w(log tmp).each { |dir|
54
+ system("touch #{dir}/.gitignore") if File.directory?(dir)
55
+ }
56
+ end
57
+
58
+ desc "Create remote origin for current dir"
59
+ task :create_remote_origin do
60
+ File.directory?('.git') || init
61
+
62
+ # Push to remote git repo
63
+ hostname = capture "echo $CAPISTRANO:HOST$"
64
+ system "git remote add origin git@#{hostname.chomp}:#{application}"
65
+ system "git push origin master:refs/heads/master"
66
+
67
+ puts
68
+ puts "New remote Git repo: #{git_user}@#{hostname.chomp}:#{application}"
69
+ puts
70
+
71
+ # File.open('.git/config', 'w') do |c|
72
+ # c.write 'Add the following to .git/config'
73
+ # c.write '[branch "master"]'
74
+ # c.write ' remote = origin'
75
+ # c.write ' merge = refs/heads/master'
76
+ # end
77
+
78
+ end
79
+
80
+ # Create root dir for git repositories
81
+ task :create_git_root do
82
+ deprec2.mkdir(git_root, :mode => 02775, :owner => git_user, :group => git_group, :via => :sudo)
83
+ sudo "chmod -R g+w #{git_root}"
84
+ end
85
+
86
+ # regenerate git authorized keys file from users file in same dir
87
+ task :regenerate_authorized_keys do
88
+ sudo "echo '' > #{git_keys_file}"
89
+ sudo "for file in `ls #{git_keys_file}-*`; do cat $file >> #{git_keys_file}; echo \"\n\" >> #{git_keys_file} ; done"
90
+ sudo "chown #{git_user}.#{git_group} #{git_keys_file}"
91
+ sudo "chmod 0600 #{git_keys_file}"
92
+ end
93
+
94
+
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,55 @@
1
+ # Not working
2
+ #
3
+ # # Copyright 2006-2008 by Mike Bailey. All rights reserved.
4
+ # Capistrano::Configuration.instance(:must_exist).load do
5
+ # namespace :deprec do
6
+ # namespace :gitosis do
7
+ #
8
+ # # ref: http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way
9
+ #
10
+ # set :gitosis_user, 'git'
11
+ #
12
+ # SRC_PACKAGES[:gitosis] = {
13
+ # :url => "git://eagain.net/gitosis.git",
14
+ # :download_method => :git,
15
+ # :configure => '',
16
+ # :make => '',
17
+ # :install => '#{sudo} python setup.py install'
18
+ # }
19
+ #
20
+ # desc "Install gitosis"
21
+ # task :install do
22
+ # install_deps
23
+ # deprec2.download_src(SRC_PACKAGES[:gitosis], src_dir)
24
+ # deprec2.install_from_src(SRC_PACKAGES[:gitosis], src_dir)
25
+ # create_user
26
+ # init
27
+ # end
28
+ #
29
+ # # install dependencies for nginx
30
+ # task :install_deps do
31
+ # apt.install( {:base => %w(python-setuptools)}, :stable )
32
+ # end
33
+ #
34
+ # # Create user for gitosis to run as
35
+ # # This will also be the account you use for ssh access to git
36
+ # task :create_user do
37
+ # run "grep '^#{gitosis_user}:' /etc/passwd || #{sudo} adduser --system --shell /bin/sh --gecos 'git version control' --group --disabled-password --home /home/#{gitosis_user} #{gitosis_user}"
38
+ # sudo "passwd --unlock #{gitosis_user}"
39
+ # end
40
+ #
41
+ # task :init do
42
+ # sudo "sudo -H -u #{git_user} gitosis-init < ~/.ssh/authorized_keys"
43
+ # sudo "chmod 0755 /home/git/repositories/gitosis-admin.git/hooks/post-update"
44
+ # puts
45
+ # puts "Now check out the gitosis-admin repo, edit configs and push changes back"
46
+ # puts "Your changes with update gitosis as soon as they are checked in."
47
+ # puts
48
+ # puts "git clone git@YOUR_SERVER_HOSTNAME:gitosis-admin.git"
49
+ # puts "cd gitosis-admin"
50
+ # puts ""
51
+ # end
52
+ #
53
+ # end
54
+ # end
55
+ # end