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,194 @@
1
+ # Copyright 2006-2010 by Mike Bailey, le1t0@github. All rights reserved.
2
+
3
+ def run_mysql_command(command, user = "root", password = nil, database=nil)
4
+ database = database.nil? ? "" : " #{database}"
5
+ password = password.nil? ? "" : " -p #{password}"
6
+ run "echo \"#{command}\" | mysql -u #{user} #{password} #{database}"
7
+ end
8
+
9
+ Capistrano::Configuration.instance(:must_exist).load do
10
+ namespace :deprec do
11
+ namespace :mysql do
12
+
13
+ set :mysql_admin_user, 'root'
14
+ set(:mysql_admin_pass) { Capistrano::CLI.password_prompt "Enter database password for '#{mysql_admin_user}':"}
15
+
16
+ SRC_PACKAGES[:percona_backup] = {
17
+ :filename => 'xtrabackup-1.0.tar.gz',
18
+ :dir => 'xtrabackup-1.0',
19
+ :url => "http://www.percona.com/mysql/xtrabackup/1.0/binary/xtrabackup-1.0.tar.gz",
20
+ :unpack => "tar zxf xtrabackup-1.0.tar.gz;",
21
+ :configure => 'echo > /dev/null;',
22
+ :make => 'echo > /dev/null;',
23
+ :install => 'mv /usr/local/src/xtrabackup-1.0/bin/* /usr/local/bin/;'
24
+ }
25
+
26
+ # Installation
27
+
28
+ desc "Install mysql"
29
+ task :install, :roles => :db do
30
+ install_deps
31
+ config
32
+ start
33
+ # symlink_mysql_sockfile # XXX still needed?
34
+ end
35
+
36
+ # Install dependencies for Mysql
37
+ task :install_deps, :roles => :db do
38
+ apt.install( {:base => %w(mysql-server mysql-client libmysqlclient15-dev)}, :stable )
39
+ end
40
+
41
+ desc "Install percona backup utility"
42
+ task :install_percona_backup, :roles => :db do
43
+ deprec2.download_src(SRC_PACKAGES[:percona_backup], src_dir)
44
+ deprec2.install_from_src(SRC_PACKAGES[:percona_backup], src_dir)
45
+ end
46
+
47
+ # Configuration
48
+
49
+ SYSTEM_CONFIG_FILES[:mysql] = [
50
+
51
+ {:template => "my.cnf.erb",
52
+ :path => '/etc/mysql/my.cnf',
53
+ :mode => 0644,
54
+ :owner => 'root:root'}
55
+ ]
56
+
57
+ desc "Generate configuration file(s) for mysql from template(s)"
58
+ task :config_gen do
59
+ SYSTEM_CONFIG_FILES[:mysql].each do |file|
60
+ deprec2.render_template(:mysql, file)
61
+ end
62
+ end
63
+
64
+ desc "Push mysql config files to server"
65
+ task :config, :roles => :db do
66
+ deprec2.push_configs(:mysql, SYSTEM_CONFIG_FILES[:mysql])
67
+ reload
68
+ end
69
+
70
+ task :activate, :roles => :db do
71
+ send(run_method, "update-rc.d mysql defaults")
72
+ end
73
+
74
+ task :deactivate, :roles => :db do
75
+ send(run_method, "update-rc.d -f mysql remove")
76
+ end
77
+
78
+ # Control
79
+
80
+ desc "Start Mysql"
81
+ task :start, :roles => :db do
82
+ send(run_method, "/etc/init.d/mysql start")
83
+ end
84
+
85
+ desc "Stop Mysql"
86
+ task :stop, :roles => :db do
87
+ send(run_method, "/etc/init.d/mysql stop")
88
+ end
89
+
90
+ desc "Restart Mysql"
91
+ task :restart, :roles => :db do
92
+ send(run_method, "/etc/init.d/mysql restart")
93
+ end
94
+
95
+ desc "Reload Mysql"
96
+ task :reload, :roles => :db do
97
+ send(run_method, "/etc/init.d/mysql reload")
98
+ end
99
+
100
+
101
+ task :backup, :roles => :db do
102
+ end
103
+
104
+ task :restore, :roles => :db do
105
+ end
106
+
107
+ desc "Create a mysql user"
108
+ task :create_user, :roles => :db do
109
+ # TBA
110
+ end
111
+
112
+ desc "Create a database"
113
+ task :create_database, :roles => :db do
114
+ cmd = "CREATE DATABASE IF NOT EXISTS #{db_name}"
115
+ run "mysql -u #{mysql_admin_user} -p -e '#{cmd}'" do |channel, stream, data|
116
+ if data =~ /^Enter password:/
117
+ channel.send_data "#{mysql_admin_pass}\n"
118
+ end
119
+ end
120
+ end
121
+
122
+ desc "Grant user access to database"
123
+ task :grant_user_access_to_database, :roles => :db do
124
+ cmd = "GRANT ALL PRIVILEGES ON #{db_name}.* TO '#{db_user}'@localhost IDENTIFIED BY '#{db_password}';"
125
+ run "mysql -u #{mysql_admin_user} -p #{db_name} -e \"#{cmd}\"" do |channel, stream, data|
126
+ if data =~ /^Enter password:/
127
+ channel.send_data "#{mysql_admin_pass}\n"
128
+ end
129
+ end
130
+ end
131
+
132
+ namespace :utils do
133
+
134
+ task :show_slave_status, :roles => :db do
135
+ run_mysql_command("SHOW SLAVE STATUS\\G")
136
+ end
137
+
138
+ task :show_master_status, :roles => :db do
139
+ run_mysql_command("SHOW MASTER STATUS;")
140
+ end
141
+
142
+ task :show_status, :roles => :db do
143
+ run_mysql_command("SHOW STATUS;")
144
+ end
145
+
146
+ task :show_variables, :roles => :db do
147
+ run_mysql_command("SHOW VARIABLES;")
148
+ end
149
+
150
+ task :show_global_variables, :roles => :db do
151
+ run_mysql_command("SHOW GLOBAL VARIABLES;")
152
+ end
153
+
154
+ task :start_slave, :roles => :db do
155
+ run_mysql_command("START SLAVE;")
156
+ end
157
+
158
+ task :stop_slave, :roles => :db do
159
+ run_mysql_command("STOP SLAVE;")
160
+ end
161
+
162
+ end
163
+
164
+ end
165
+ end
166
+ end
167
+
168
+ #
169
+ # Setup replication
170
+ #
171
+
172
+ # setup user for repl
173
+ # GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%.yourdomain.com' IDENTIFIED BY 'slavepass';
174
+
175
+ # get current position of binlog
176
+ # mysql> FLUSH TABLES WITH READ LOCK;
177
+ # Query OK, 0 rows affected (0.00 sec)
178
+ #
179
+ # mysql> SHOW MASTER STATUS;
180
+ # +------------------+----------+--------------+------------------+
181
+ # | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
182
+ # +------------------+----------+--------------+------------------+
183
+ # | mysql-bin.000012 | 296 | | |
184
+ # +------------------+----------+--------------+------------------+
185
+ # 1 row in set (0.00 sec)
186
+ #
187
+ # # get current data
188
+ # mysqldump --all-databases --master-data >dbdump.db
189
+ #
190
+ # UNLOCK TABLES;
191
+
192
+
193
+ # Replication Features and Issues
194
+ # http://dev.mysql.com/doc/refman/5.0/en/replication-features.html
@@ -0,0 +1,104 @@
1
+ # Copyright 2006-2008 by Saulius Grigaitis. All rights reserved.
2
+ # Backported from centostrano to deprec by Eric Harris-Braun.
3
+ Capistrano::Configuration.instance(:must_exist).load do
4
+ namespace :deprec do
5
+ namespace :postgresql do
6
+
7
+ # Installation
8
+ desc "Install postgresql"
9
+ task :install, :roles => :db do
10
+ install_deps
11
+ end
12
+
13
+ # Install dependencies for PostgreSQL
14
+ task :install_deps, :roles => :db do
15
+ apt.install( {:base => %w(postgresql postgresql-client libpq-dev)}, :stable )
16
+ end
17
+
18
+ # Configuration
19
+
20
+ SYSTEM_CONFIG_FILES[:postgresql] = [
21
+
22
+ {:template => "pg_hba.conf.erb",
23
+ :path => '/var/lib/pgsql/data/pg_hba.conf',
24
+ :mode => 0644,
25
+ :owner => 'root:root'}
26
+ ]
27
+
28
+ desc "Generate configuration file(s) for postgresql from template(s)"
29
+ task :config_gen do
30
+ SYSTEM_CONFIG_FILES[:postgresql].each do |file|
31
+ deprec2.render_template(:postgresql, file)
32
+ end
33
+ end
34
+
35
+ desc "Push postgresql config files to server"
36
+ task :config, :roles => :db do
37
+ deprec2.push_configs(:postgresql, SYSTEM_CONFIG_FILES[:postgresql])
38
+ end
39
+
40
+ task :activate, :roles => :db do
41
+ send(run_method, "update-rc.d postgresql-8.3 defaults")
42
+ end
43
+
44
+ task :deactivate, :roles => :db do
45
+ send(run_method, "update-rc.d -f postgresql-8.3 remove")
46
+ end
47
+
48
+ # Control
49
+
50
+ desc "Start PostgreSQL"
51
+ task :start, :roles => :db do
52
+ send(run_method, "/etc/init.d/postgresql-8.3 start")
53
+ end
54
+
55
+ desc "Stop PostgreSQL"
56
+ task :stop, :roles => :db do
57
+ send(run_method, "/etc/init.d/postgresql-8.3 stop")
58
+ end
59
+
60
+ desc "Restart PostgreSQL"
61
+ task :restart, :roles => :db do
62
+ send(run_method, "/etc/init.d/postgresql-8.3 restart")
63
+ end
64
+
65
+ desc "Reload PostgreSQL"
66
+ task :reload, :roles => :db do
67
+ send(run_method, "/etc/init.d/postgresql-8.3 reload")
68
+ end
69
+
70
+ task :backup, :roles => :db do
71
+ end
72
+
73
+ task :restore, :roles => :db do
74
+ end
75
+
76
+ desc "Create a PostgreSQL user"
77
+ task :create_user, :roles => :db do
78
+ cmd = "su - postgres -c \'createuser -P -D -A -E #{db_user}\'"
79
+ sudo cmd do |channel, stream, data|
80
+ if data =~ /^Enter password for new/
81
+ channel.send_data "#{db_password}\n"
82
+ end
83
+ if data =~ /^Enter it again:/
84
+ channel.send_data "#{db_password}\n"
85
+ end
86
+ if data =~ /^Shall the new role be allowed to create more new roles?/
87
+ channel.send_data "n\n"
88
+ end
89
+ end
90
+ end
91
+
92
+ desc "Create a PostgreSQL Database"
93
+ task :create_database, :roles => :db do
94
+ sudo "su - postgres -c \'createdb -O #{db_user} #{db_name}\'"
95
+ end
96
+
97
+ desc "Grant user access to Database"
98
+ task :grant_user_access_to_database, :roles => :db do
99
+ # sudo "what's the command for this using #{db_user} #{db_name}\'"
100
+ end
101
+
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,37 @@
1
+ # Copyright 2006-2009 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :sqlite do
5
+
6
+ desc "Install sqlite"
7
+ task :install, :roles => :db do
8
+ install_deps
9
+ gem2.install "sqlite3-ruby"
10
+ end
11
+
12
+ # install dependencies for nginx
13
+ task :install_deps, :roles => :db do
14
+ apt.install( {:base => %w(sqlite3 libsqlite3-ruby libsqlite3-dev)}, :stable )
15
+ end
16
+ end
17
+
18
+ desc "Create a PostgreSQL user"
19
+ task :create_user do
20
+ # Not needed for sqlite
21
+ # We need these stubs for deprec:rails:setup_database
22
+ end
23
+
24
+ desc "Create a PostgreSQL Database"
25
+ task :create_database do
26
+ # Not needed for sqlite
27
+ # We need these stubs for deprec:rails:setup_database
28
+ end
29
+
30
+ desc "Grant user access to Database"
31
+ task :grant_user_access_to_database do
32
+ # Not needed for sqlite
33
+ # We need these stubs for deprec:rails:setup_database
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,51 @@
1
+ # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+ namespace :deprec do
4
+ namespace :ddclient do
5
+
6
+ set(:ddclient_user) { Capistrano::CLI.ui.ask "Enter ddclient username" }
7
+ set(:ddclient_pass) { Capistrano::CLI.ui.ask "Enter ddclient password" }
8
+ set(:ddclient_domains) { Capistrano::CLI.ui.ask "Enter ddclient domain" }
9
+ set(:ddclient_interface) {
10
+ Capistrano::CLI.ui.ask "Enter ddclient interface" do |q|
11
+ q.default = 'eth0'
12
+ end
13
+ }
14
+
15
+ desc "Install ddclient"
16
+ task :install do
17
+ install_deps
18
+ end
19
+
20
+ # install dependencies for ddclient
21
+ task :install_deps do
22
+ apt.install( {:base => %w(ddclient)}, :stable )
23
+ end
24
+
25
+ SYSTEM_CONFIG_FILES[:ddclient] = [
26
+ { :template => "ddclient.conf.erb",
27
+ :path => '/etc/ddclient.conf',
28
+ :mode => 0600,
29
+ :owner => 'root:root'},
30
+
31
+ { :template => "ddclient.erb",
32
+ :path => '/etc/default/ddclient',
33
+ :mode => 0600,
34
+ :owner => 'root:root'}
35
+ ]
36
+
37
+ desc "Update system networking configuration"
38
+ task :config do
39
+ SYSTEM_CONFIG_FILES[:ddclient].each do |file|
40
+ deprec2.render_template(:ddclient, file.merge(:remote=>true))
41
+ end
42
+ start
43
+ end
44
+
45
+ task :start do
46
+ sudo '/etc/init.d/ddclient start'
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,167 @@
1
+ # Copyright 2006-2010 by Mike Bailey, le1t0@github. All rights reserved.
2
+ Capistrano::Configuration.instance(:must_exist).load do
3
+
4
+ # Set the value if not already set
5
+ # This method is accessible to all recipe files
6
+ def self.default(name, *args, &block)
7
+ unless exists?(name)
8
+ set(name, *args, &block)
9
+ end
10
+ end
11
+
12
+ # Deprec checks here for local versions of config templates before it's own
13
+ set :local_template_dir, File.join('config','templates')
14
+
15
+ # The following two Constants contain details of the configuration
16
+ # files used by each service. They're used when generating config
17
+ # files from templates and when configs files are pushed out to servers.
18
+ #
19
+ # They are populated by the recipe file for each service
20
+ #
21
+ SYSTEM_CONFIG_FILES = {} # e.g. httpd.conf
22
+ PROJECT_CONFIG_FILES = {} # e.g. projectname-httpd-vhost.conf
23
+
24
+ # For each service, the details of the file to download and options
25
+ # to configure, build and install the service
26
+ SRC_PACKAGES = {} unless defined?(SRC_PACKAGES)
27
+
28
+ # Service defaults
29
+ #
30
+ Dir.glob("#{File.dirname(__FILE__)}/*").each do |entry|
31
+ default "#{File.basename(entry)}_choice".to_sym, :none if File.directory?(entry)
32
+ end
33
+
34
+ default(:application) do
35
+ Capistrano::CLI.ui.ask "Enter name of project(no spaces)" do |q|
36
+ q.validate = /^[0-9a-z_]*$/
37
+ end
38
+ end
39
+
40
+ default(:domain) do
41
+ Capistrano::CLI.ui.ask "Enter domain name for project" do |q|
42
+ q.validate = /^[0-9a-z_\.]*$/
43
+ end
44
+ end
45
+
46
+ default(:repository) do
47
+ Capistrano::CLI.ui.ask "Enter repository URL for project" do |q|
48
+ # q.validate = //
49
+ end
50
+ end
51
+
52
+ # some tasks run commands requiring special user privileges on remote servers
53
+ # these tasks will run the commands with:
54
+ # :invoke_command "command", :via => run_method
55
+ # override this value if sudo is not an option
56
+ # in that case, your use will need the correct privileges
57
+ default :run_method, :sudo
58
+
59
+ default(:backup_dir) { '/var/backups'}
60
+
61
+ # XXX rails deploy stuff
62
+ set :apps_root, File.join( %w(/ opt apps) ) # parent dir for apps
63
+ default(:deploy_to) { File.join(apps_root, application) } # dir for current app
64
+ default(:current_path) { File.join(deploy_to, "current") }
65
+ default(:shared_path) { File.join(deploy_to, "shared") }
66
+
67
+ # XXX more rails deploy stuff?
68
+
69
+ default :user, ENV['USER'] # user who is deploying
70
+ default :group, 'deploy' # deployment group
71
+ default(:group_src) { group } # group ownership for src dir
72
+ default :src_dir, '/usr/local/src' # 3rd party src on servers lives here
73
+ default(:web_server_aliases) { domain.match(/^www/) ? [] : ["www.#{domain}"] }
74
+
75
+ # XXX for some reason this is causing "before deprec:rails:install" to be executed twice
76
+ on :load, 'deprec:connect_canonical_tasks'
77
+
78
+ namespace :deprec do
79
+
80
+ task :connect_canonical_tasks do
81
+ # link application specific recipes into canonical task names
82
+ # e.g. deprec:web:restart => deprec:nginx:restart
83
+
84
+
85
+ namespaces_to_connect = Hash[*(Dir.glob("#{File.dirname(__FILE__)}/*").collect do |entry|
86
+ [ File.basename(entry).to_sym, "#{File.basename(entry)}_choice".to_sym ] if File.directory?(entry)
87
+ end.compact.flatten)]
88
+ metaclass = class << self; self; end # XXX unnecessary?
89
+ namespaces_to_connect.each do |server, choice|
90
+ server_type = send(choice).to_sym
91
+ if server_type != :none
92
+ metaclass.send(:define_method, server) { namespaces[server] } # XXX unnecessary?
93
+ namespaces[server] = deprec.send(server_type)
94
+ end
95
+ end
96
+ end
97
+
98
+ task :dump do
99
+ require 'yaml'
100
+ y variables
101
+ end
102
+
103
+ task :setup_src_dir do
104
+ deprec2.groupadd(group_src)
105
+ deprec2.add_user_to_group(user, group_src)
106
+ deprec2.create_src_dir
107
+ end
108
+
109
+ # Download all packages used by deprec to your local host.
110
+ # You can then push them to /usr/local/src on target hosts
111
+ # to save time and bandwidth rather than repeatedly downloading
112
+ # from the distribution sites.
113
+ task :update_src do
114
+ SRC_PACKAGES.each{|key, src_package|
115
+ current_dir = Dir.pwd
116
+ system "cd src/ && test -f #{src_package[:filename]} || wget --quiet --timestamping #{src_package[:url]}"
117
+ system "cd #{current_dir}"
118
+ }
119
+ end
120
+
121
+ # todo
122
+ #
123
+ # Copy files from src/ to /usr/local/src/ on remote hosts
124
+ task :push_src do
125
+ SRC_PACKAGES.each do |key, src_package|
126
+ deprec2.set_package_defaults(src_package)
127
+ file = File.join('src', src_package[:filename])
128
+ if File.exists?(file)
129
+ std.su_put(File.read(file), "#{src_dir}/#{src_package[:filename]}", '/tmp/')
130
+ end
131
+ end
132
+ end
133
+
134
+ task :list_src do
135
+ # XXX ugly line - look away
136
+ max_key_size = SRC_PACKAGES.keys.max{|a,b| a.to_s.size <=> b.to_s.size}.to_s.size
137
+ SRC_PACKAGES.each{|key, src_package|
138
+ deprec2.set_package_defaults(src_package)
139
+ puts "#{key}#{' '*(max_key_size+1-key.to_s.size)}: #{src_package[:url]}"
140
+ }
141
+ end
142
+
143
+ task :find_src do
144
+ # XXX ugly line - look away
145
+ max_key_size = SRC_PACKAGES.keys.max{|a,b| a.to_s.size <=> b.to_s.size}.to_s.size
146
+ SRC_PACKAGES.each{|key, src_package|
147
+ deprec2.set_package_defaults(src_package)
148
+ puts "#{key}#{' '*(max_key_size+1-key.to_s.size)}: #{src_package[:url]}"
149
+ puts `find . -name #{src_package[:filename]}`
150
+ puts
151
+ }
152
+ end
153
+
154
+ task :recover_src do
155
+ # XXX ugly line - look away
156
+ max_key_size = SRC_PACKAGES.keys.max{|a,b| a.to_s.size <=> b.to_s.size}.to_s.size
157
+ SRC_PACKAGES.each{|key, src_package|
158
+ puts "#{key}#{' '*(max_key_size+1-key.to_s.size)}: #{src_package[:url]}"
159
+ file = `find . -name #{src_package[:filename]}`.split[0]
160
+ `cp #{file} src/` if file
161
+ puts
162
+ }
163
+ end
164
+
165
+ end
166
+
167
+ end