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,90 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :users do
5
+
6
+ # desc "Create user account"
7
+ # task :add do
8
+ # target_user = Capistrano::CLI.ui.ask "Enter userid for new user" do |q|
9
+ # q.default = user
10
+ # end
11
+ # deprec2.useradd(target_user, :shell => '/bin/bash')
12
+ # puts "Setting password for new account"
13
+ # deprec2.invoke_with_input("passwd #{target_user}", /UNIX password/)
14
+ # end
15
+
16
+ desc "Create account"
17
+ task :add do
18
+ target_user = Capistrano::CLI.ui.ask "Enter userid for new user" do |q|
19
+ q.default = user
20
+ end
21
+ make_admin = Capistrano::CLI.ui.ask "Should this be an admin account?" do |q|
22
+ q.default = 'no'
23
+ end
24
+ copy_keys = false
25
+ if File.readable?("config/ssh/authorized_keys/#{target_user}")
26
+ copy_keys = Capistrano::CLI.ui.ask "I've found an authorized_keys file for #{target_user}. Should I copy it out?" do |q|
27
+ q.default = 'yes'
28
+ end
29
+ end
30
+
31
+ new_password = Capistrano::CLI.ui.ask("Enter new password for #{target_user}") { |q| q.echo = false }
32
+
33
+ deprec2.useradd(target_user, :shell => '/bin/bash')
34
+
35
+ deprec2.invoke_with_input("passwd #{target_user}", /UNIX password/, new_password)
36
+
37
+ if make_admin.match(/y/i)
38
+ deprec2.groupadd('admin')
39
+ deprec2.add_user_to_group(target_user, 'admin')
40
+ deprec2.append_to_file_if_missing('/etc/sudoers', '%admin ALL=(ALL) ALL')
41
+ end
42
+
43
+ if copy_keys && copy_keys.grep(/y/i)
44
+ set :target_user, target_user
45
+ top.deprec.ssh.setup_keys
46
+ end
47
+
48
+ end
49
+
50
+ desc "Create account"
51
+ task :add_admin do
52
+ puts 'deprecated! use deprec:users:add'
53
+ add
54
+ end
55
+
56
+ desc "Change user password"
57
+ task :passwd do
58
+ target_user = Capistrano::CLI.ui.ask "Enter user to change password for" do |q|
59
+ q.default = user if user.is_a?(String)
60
+ end
61
+ new_password = Capistrano::CLI.ui.ask("Enter new password for #{target_user}") { |q| q.echo = false }
62
+
63
+ deprec2.invoke_with_input("passwd #{target_user}", /UNIX password/, new_password)
64
+ end
65
+
66
+ desc "Add user to group"
67
+ task :add_user_to_group do
68
+ target_user = Capistrano::CLI.ui.ask "Which user?" do |q|
69
+ q.default = user if user.is_a?(String)
70
+ end
71
+ target_group = Capistrano::CLI.ui.ask "Add to which group?" do |q|
72
+ q.default = 'deploy'
73
+ end
74
+ deprec2.add_user_to_group(target_user, target_group)
75
+ end
76
+
77
+ # desc "Create group"
78
+ # task :add_group do
79
+ # target_group = Capistrano::CLI.ui.ask "Enter name for new group"
80
+ # deprec2.groupadd(target_group)
81
+ # end
82
+ #
83
+ # desc "Add user to group"
84
+ # task :add_user_to_group do
85
+ # # XXX not yet implemented
86
+ # end
87
+
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,58 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :utils do
5
+
6
+ SRC_PACKAGES[:daemonize] = {
7
+ :filename => 'daemonize-1.5.6.tar.gz',
8
+ :md5sum => "2f5fbb8788ebe803ccaff3cd4b5c3188 daemonize-1.5.6.tar.gz",
9
+ :dir => 'daemonize-1.5.6',
10
+ :url => "http://www.clapper.org/software/daemonize/daemonize-1.5.6.tar.gz",
11
+ :unpack => "tar zxf daemonize-1.5.6.tar.gz;",
12
+ :configure => %w(
13
+ ./configure
14
+ ;
15
+ ).reject{|arg| arg.match '#'}.join(' '),
16
+ :make => 'make;',
17
+ :install => 'make install;'
18
+ }
19
+
20
+ namespace :daemonize do
21
+
22
+ desc "Install daemonize"
23
+ task :install do
24
+ deprec2.download_src(SRC_PACKAGES[:daemonize], src_dir)
25
+ deprec2.install_from_src(SRC_PACKAGES[:daemonize], src_dir)
26
+ end
27
+
28
+ end
29
+
30
+ desc "Install some useful network utils"
31
+ task :net do
32
+ apps = %w(lynx nmap netcat telnet dnsutils rsync curl wget)
33
+ apt.install( {:base => apps}, :stable )
34
+ end
35
+
36
+ desc "Install some useful mail utils"
37
+ task :mail do
38
+ apps = %w(mailx mutt)
39
+ apt.install( {:base => apps}, :stable )
40
+ end
41
+
42
+ desc "Install some useful utils"
43
+ task :other do
44
+ apps = %w(lsof vim tree psmisc screen)
45
+ apt.install( {:base => apps}, :stable )
46
+ end
47
+
48
+ desc "Install handy utils"
49
+ task :handy do
50
+ net
51
+ mail
52
+ other
53
+ end
54
+
55
+ end
56
+ end
57
+ end
58
+
@@ -0,0 +1,85 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+
4
+ namespace :deprec do
5
+ namespace :vnstat do
6
+
7
+ desc <<-EOF
8
+ vnstat description
9
+ EOF
10
+ task :default do
11
+ end
12
+
13
+ SRC_PACKAGES[:vnstat] = {
14
+ :url => "http://humdi.net/vnstat/vnstat-1.6.tar.gz",
15
+ :md5sum => "ccaffe8e70d47e0cf2f25e52daa25712 vnstat-1.6.tar.gz",
16
+ :configure => '',
17
+ :post_install => 'vnstat --testkernel && vnstat -u -i eth0'
18
+ }
19
+
20
+ desc <<-EOF
21
+ Install vnstat. Add interfaces with 'vnstat -u -i ethN'
22
+ (where N is interface number).
23
+
24
+ View stats using the vnstat command line tool.
25
+ EOF
26
+ task :install do
27
+ install_deps
28
+ deprec2.download_src(SRC_PACKAGES[:vnstat], src_dir)
29
+ deprec2.install_from_src(SRC_PACKAGES[:vnstat], src_dir)
30
+ end
31
+
32
+ # install dependencies for monit
33
+ task :install_deps do
34
+ # apt.install( {:base => %w(flex bison libssl-dev)}, :stable )
35
+ end
36
+
37
+ end
38
+
39
+
40
+ namespace :vnstat_php do
41
+
42
+ SRC_PACKAGES[:vnstat_php] = {
43
+ :url => "http://www.sqweek.com/sqweek/files/vnstat_php_frontend-1.3.tar.gz",
44
+ :md5sum => "190b37808ae16bd1c1a132434b170437 vnstat_php_frontend-1.3.tar.gz",
45
+ :configure => '',
46
+ :make => '',
47
+ :install => "test -d /var/www/vnstat_php_frontend-1.3 && rm -fr /var/www/vnstat_php_frontend-1.3; mv #{src_dir}/vnstat_php_frontend-1.3 /var/www &&
48
+ ln -sf /var/www/vnstat_php_frontend-1.3 /var/www/vnstat"
49
+ }
50
+
51
+ task :install do
52
+ install_deps
53
+ deprec2.download_src(SRC_PACKAGES[:vnstat_php], src_dir)
54
+ deprec2.install_from_src(SRC_PACKAGES[:vnstat_php], src_dir)
55
+ end
56
+
57
+ # install dependencies for monit
58
+ task :install_deps do
59
+ apt.install( {:base => %w(apache2 php5 php5-gd)}, :stable )
60
+ end
61
+
62
+ SYSTEM_CONFIG_FILES[:vnstat] = [
63
+
64
+ {:template => 'config.php',
65
+ :path => '/var/www/vnstat',
66
+ :mode => 0755,
67
+ :owner => 'root:root'}
68
+
69
+ ]
70
+
71
+ task :config_gen do
72
+ SYSTEM_CONFIG_FILES[:vnstat].each do |file|
73
+ deprec2.render_template(:vnstat, file)
74
+ end
75
+ end
76
+
77
+ desc "Push monit config files to server"
78
+ task :config do
79
+ deprec2.push_configs(:vnstat, SYSTEM_CONFIG_FILES[:vnstat])
80
+ end
81
+
82
+ end
83
+
84
+ end
85
+ end
@@ -0,0 +1,143 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :apache do
5
+
6
+ set :apache_user, 'www-data'
7
+ set :apache_vhost_dir, '/etc/apache2/sites-available'
8
+ set :apache_ssl_enabled, false
9
+ set :apache_ssl_ip, nil
10
+ set :apache_ssl_forward_all, apache_ssl_enabled
11
+ set :apache_ssl_chainfile, false
12
+ set :apache_modules_enabled, %w(rewrite ssl proxy_balancer proxy_http deflate headers)
13
+ set :apache_log_dir, '/var/log/apache2'
14
+
15
+ desc "Install apache"
16
+ task :install do
17
+ install_deps
18
+ enable_modules
19
+ reload
20
+ end
21
+
22
+ # install dependencies for apache
23
+ task :install_deps do
24
+ apt.install( {:base => %w(apache2-mpm-prefork apache2-prefork-dev rsync ssl-cert)}, :stable )
25
+ end
26
+
27
+ SYSTEM_CONFIG_FILES[:apache] = [
28
+
29
+ { :template => 'namevirtualhosts.conf',
30
+ :path => '/etc/apache2/conf.d/namevirtualhosts.conf',
31
+ :mode => 0644,
32
+ :owner => 'root:root'},
33
+
34
+ { :template => 'ports.conf.erb',
35
+ :path => '/etc/apache2/ports.conf',
36
+ :mode => 0644,
37
+ :owner => 'root:root'},
38
+
39
+ { :template => 'status.conf.erb',
40
+ :path => '/etc/apache2/mods-available/status.conf',
41
+ :mode => 0644,
42
+ :owner => 'root:root'}
43
+
44
+ ]
45
+
46
+ PROJECT_CONFIG_FILES[:apache] = [
47
+ # Not required
48
+ ]
49
+
50
+ desc "Generate configuration file(s) for apache from template(s)"
51
+ task :config_gen do
52
+ config_gen_system
53
+ end
54
+
55
+ task :config_gen_system do
56
+ SYSTEM_CONFIG_FILES[:apache].each do |file|
57
+ deprec2.render_template(:apache, file)
58
+ end
59
+ end
60
+
61
+ task :config_gen_project do
62
+ PROJECT_CONFIG_FILES[:apache].each do |file|
63
+ deprec2.render_template(:apache, file)
64
+ end
65
+ # XXX Need to flesh out generation of custom certs
66
+ # In the meantime we'll just use the snakeoil cert
67
+ #
68
+ # top.deprec.ssl.config_gen if apache_ssl_enabled
69
+ top.deprec.ssl.config_gen if apache_ssl_enabled
70
+ end
71
+
72
+ desc "Push apache config files to server"
73
+ task :config, :roles => :web do
74
+ config_system
75
+ reload
76
+ end
77
+
78
+ desc "Generate initial configs and copy direct to server."
79
+ task :initial_config, :roles => :web do
80
+ SYSTEM_CONFIG_FILES[:apache].each do |file|
81
+ deprec2.render_template(:apache, file.merge(:remote => true))
82
+ end
83
+ end
84
+
85
+ desc "Push apache config files to server"
86
+ task :config_system, :roles => :web do
87
+ deprec2.push_configs(:apache, SYSTEM_CONFIG_FILES[:apache])
88
+ end
89
+
90
+ # Stub so generic tasks don't fail (e.g. deprec:web:config_project)
91
+ task :config_project do
92
+ # XXX Need to flesh out generation of custom certs
93
+ # In the meantime we'll just use the snakeoil cert
94
+ #
95
+ top.deprec.ssl.config if apache_ssl_enabled
96
+ end
97
+
98
+ task :enable_modules, :roles => :web do
99
+ apache_modules_enabled.each { |mod| sudo "a2enmod #{mod}" }
100
+ reload
101
+ end
102
+
103
+ desc "Start Apache"
104
+ task :start, :roles => :web do
105
+ send(run_method, "/etc/init.d/apache2 start")
106
+ end
107
+
108
+ desc "Stop Apache"
109
+ task :stop, :roles => :web do
110
+ send(run_method, "/etc/init.d/apache2 stop")
111
+ end
112
+
113
+ desc "Restart Apache"
114
+ task :restart, :roles => :web do
115
+ send(run_method, "/etc/init.d/apache2 restart")
116
+ end
117
+
118
+ desc "Reload Apache"
119
+ task :reload, :roles => :web do
120
+ send(run_method, "/etc/init.d/apache2 force-reload")
121
+ end
122
+
123
+ desc "Set apache to start on boot"
124
+ task :activate, :roles => :web do
125
+ send(run_method, "update-rc.d apache2 defaults")
126
+ end
127
+
128
+ desc "Set apache to not start on boot"
129
+ task :deactivate, :roles => :web do
130
+ send(run_method, "update-rc.d -f apache2 remove")
131
+ end
132
+
133
+ task :backup, :roles => :web do
134
+ # not yet implemented
135
+ end
136
+
137
+ task :restore, :roles => :web do
138
+ # not yet implemented
139
+ end
140
+
141
+ end
142
+ end
143
+ end
@@ -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.7.59.tar.gz",
15
+ :md5sum => "d981b03b4c3ba43de580553355608b63 nginx-0.7.59.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