nirvdrum-rubber 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/CHANGELOG +146 -0
  2. data/COPYING +339 -0
  3. data/README +6 -0
  4. data/TODO +11 -0
  5. data/VERSION +1 -0
  6. data/bin/vulcanize +41 -0
  7. data/generators/vulcanize/USAGE +6 -0
  8. data/generators/vulcanize/templates/apache/config/rubber/deploy-apache.rb +51 -0
  9. data/generators/vulcanize/templates/apache/config/rubber/role/apache/deflate.conf +10 -0
  10. data/generators/vulcanize/templates/apache/config/rubber/role/apache/expires.conf +9 -0
  11. data/generators/vulcanize/templates/apache/config/rubber/role/apache/headers.conf +6 -0
  12. data/generators/vulcanize/templates/apache/config/rubber/role/apache/monit-apache.conf +8 -0
  13. data/generators/vulcanize/templates/apache/config/rubber/role/apache/ports.conf +5 -0
  14. data/generators/vulcanize/templates/apache/config/rubber/role/apache/setenvif.conf +52 -0
  15. data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache-vhost.conf +66 -0
  16. data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache.auth +7 -0
  17. data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-index.html +34 -0
  18. data/generators/vulcanize/templates/apache/config/rubber/rubber-apache.yml +6 -0
  19. data/generators/vulcanize/templates/apache/templates.yml +1 -0
  20. data/generators/vulcanize/templates/base/Capfile +14 -0
  21. data/generators/vulcanize/templates/base/config/deploy.rb +55 -0
  22. data/generators/vulcanize/templates/base/config/rubber/common/crontab +17 -0
  23. data/generators/vulcanize/templates/base/config/rubber/common/monit-postfix.conf +8 -0
  24. data/generators/vulcanize/templates/base/config/rubber/common/rubber.profile +14 -0
  25. data/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +84 -0
  26. data/generators/vulcanize/templates/base/config/rubber/rubber-dns.yml +79 -0
  27. data/generators/vulcanize/templates/base/config/rubber/rubber.yml +227 -0
  28. data/generators/vulcanize/templates/base/lib/tasks/rubber.rake +15 -0
  29. data/generators/vulcanize/templates/base/script/cron-rake +18 -0
  30. data/generators/vulcanize/templates/base/script/cron-runner +18 -0
  31. data/generators/vulcanize/templates/base/script/cron-sh +67 -0
  32. data/generators/vulcanize/templates/base/templates.yml +1 -0
  33. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/haproxy/haproxy-mongrel.conf +23 -0
  34. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/nginx/nginx-mongrel.conf +113 -0
  35. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/rubber-complete.yml +41 -0
  36. data/generators/vulcanize/templates/complete_mongrel_mysql/templates.yml +6 -0
  37. data/generators/vulcanize/templates/complete_passenger_mysql/config/rubber/role/haproxy/haproxy-passenger.conf +21 -0
  38. data/generators/vulcanize/templates/complete_passenger_mysql/config/rubber/rubber-complete.yml +40 -0
  39. data/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +10 -0
  40. data/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +72 -0
  41. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/cruise +40 -0
  42. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/my.cnf +165 -0
  43. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/production.rb +8 -0
  44. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/site_config.rb +76 -0
  45. data/generators/vulcanize/templates/cruise/config/rubber/role/web_tools/cruise-nginx.conf +11 -0
  46. data/generators/vulcanize/templates/cruise/config/rubber/rubber-cruise.yml +18 -0
  47. data/generators/vulcanize/templates/cruise/templates.yml +1 -0
  48. data/generators/vulcanize/templates/haproxy/config/rubber/deploy-haproxy.rb +45 -0
  49. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-base.conf +26 -0
  50. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-default.conf +8 -0
  51. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +9 -0
  52. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf +6 -0
  53. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslogd-default.conf +17 -0
  54. data/generators/vulcanize/templates/haproxy/config/rubber/role/web_tools/haproxy-nginx.conf +10 -0
  55. data/generators/vulcanize/templates/haproxy/config/rubber/rubber-haproxy.yml +7 -0
  56. data/generators/vulcanize/templates/haproxy/templates.yml +1 -0
  57. data/generators/vulcanize/templates/jetty/config/rubber/deploy-jetty.rb +59 -0
  58. data/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.sh +589 -0
  59. data/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.xml +199 -0
  60. data/generators/vulcanize/templates/jetty/config/rubber/role/jetty/monit-jetty.conf +9 -0
  61. data/generators/vulcanize/templates/jetty/config/rubber/rubber-jetty.yml +10 -0
  62. data/generators/vulcanize/templates/jetty/templates.yml +1 -0
  63. data/generators/vulcanize/templates/memcached/config/memcached.yml +28 -0
  64. data/generators/vulcanize/templates/memcached/config/rubber/common/memcached.yml +14 -0
  65. data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached.conf +52 -0
  66. data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached_munin_plugin +249 -0
  67. data/generators/vulcanize/templates/memcached/config/rubber/rubber-memcached.yml +7 -0
  68. data/generators/vulcanize/templates/memcached/templates.yml +1 -0
  69. data/generators/vulcanize/templates/minimal_mysql/templates.yml +7 -0
  70. data/generators/vulcanize/templates/minimal_nodb/templates.yml +6 -0
  71. data/generators/vulcanize/templates/mongrel/config/rubber/deploy-mongrel.rb +75 -0
  72. data/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/mongrel_cluster.yml +12 -0
  73. data/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/monit-mongrel.conf +20 -0
  74. data/generators/vulcanize/templates/mongrel/config/rubber/rubber-mongrel.yml +9 -0
  75. data/generators/vulcanize/templates/mongrel/templates.yml +1 -0
  76. data/generators/vulcanize/templates/monit/config/rubber/common/monit-default.conf +15 -0
  77. data/generators/vulcanize/templates/monit/config/rubber/common/monit.conf +251 -0
  78. data/generators/vulcanize/templates/monit/config/rubber/deploy-monit.rb +32 -0
  79. data/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +10 -0
  80. data/generators/vulcanize/templates/monit/config/rubber/rubber-monit.yml +6 -0
  81. data/generators/vulcanize/templates/monit/templates.yml +1 -0
  82. data/generators/vulcanize/templates/munin/config/rubber/common/monit-munin.conf +8 -0
  83. data/generators/vulcanize/templates/munin/config/rubber/common/munin-node.conf +48 -0
  84. data/generators/vulcanize/templates/munin/config/rubber/common/munin-plugins.conf +9 -0
  85. data/generators/vulcanize/templates/munin/config/rubber/deploy-munin.rb +46 -0
  86. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-nginx.conf +8 -0
  87. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-plugins.conf +31 -0
  88. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +80 -0
  89. data/generators/vulcanize/templates/munin/config/rubber/rubber-munin.yml +8 -0
  90. data/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +57 -0
  91. data/generators/vulcanize/templates/munin/script/munin/example_simple.rb +24 -0
  92. data/generators/vulcanize/templates/munin/templates.yml +1 -0
  93. data/generators/vulcanize/templates/mysql/config/rubber/common/database.yml +11 -0
  94. data/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +156 -0
  95. data/generators/vulcanize/templates/mysql/config/rubber/role/db/crontab +14 -0
  96. data/generators/vulcanize/templates/mysql/config/rubber/role/db/monit-mysql.cnf +10 -0
  97. data/generators/vulcanize/templates/mysql/config/rubber/role/db/my.cnf +167 -0
  98. data/generators/vulcanize/templates/mysql/config/rubber/role/mysql_slave/mysql_slave_munin_plugin +51 -0
  99. data/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +46 -0
  100. data/generators/vulcanize/templates/mysql/templates.yml +1 -0
  101. data/generators/vulcanize/templates/mysql_cluster/config/rubber/common/mysql_cluster_migrations.rb +13 -0
  102. data/generators/vulcanize/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb +173 -0
  103. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_data/my.cnf +15 -0
  104. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_mgm/ndb_mgmd.cnf +39 -0
  105. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf +10 -0
  106. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/my.cnf +23 -0
  107. data/generators/vulcanize/templates/mysql_cluster/config/rubber/rubber-mysql_cluster.yml +32 -0
  108. data/generators/vulcanize/templates/mysql_cluster/templates.yml +1 -0
  109. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/database.yml +16 -0
  110. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf +10 -0
  111. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +153 -0
  112. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.conf +10 -0
  113. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.lua +5 -0
  114. data/generators/vulcanize/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb +52 -0
  115. data/generators/vulcanize/templates/mysql_proxy/config/rubber/rubber-mysql_proxy.yml +11 -0
  116. data/generators/vulcanize/templates/mysql_proxy/templates.yml +1 -0
  117. data/generators/vulcanize/templates/nginx/config/rubber/deploy-nginx.rb +45 -0
  118. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/crontab +9 -0
  119. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/monit-nginx.conf +8 -0
  120. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/nginx.conf +42 -0
  121. data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
  122. data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-index.html +30 -0
  123. data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
  124. data/generators/vulcanize/templates/nginx/config/rubber/rubber-nginx.yml +10 -0
  125. data/generators/vulcanize/templates/nginx/templates.yml +1 -0
  126. data/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +37 -0
  127. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +34 -0
  128. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +7 -0
  129. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +47 -0
  130. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf +46 -0
  131. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +10 -0
  132. data/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +15 -0
  133. data/generators/vulcanize/templates/passenger/templates.yml +3 -0
  134. data/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +36 -0
  135. data/generators/vulcanize/templates/redis/config/rubber/role/redis/crontab +8 -0
  136. data/generators/vulcanize/templates/redis/config/rubber/role/redis/monit-redis.conf +9 -0
  137. data/generators/vulcanize/templates/redis/config/rubber/role/redis/redis.conf +141 -0
  138. data/generators/vulcanize/templates/redis/config/rubber/rubber-redis.yml +4 -0
  139. data/generators/vulcanize/templates/redis/templates.yml +1 -0
  140. data/generators/vulcanize/templates/resque/config/rubber/deploy-resque-worker-default.rb +38 -0
  141. data/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +39 -0
  142. data/generators/vulcanize/templates/resque/config/rubber/role/resque_worker_default/monit-resque_worker_default.conf +19 -0
  143. data/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +10 -0
  144. data/generators/vulcanize/templates/resque/templates.yml +3 -0
  145. data/generators/vulcanize/templates/sphinx/config/rubber/common/sphinx.yml +46 -0
  146. data/generators/vulcanize/templates/sphinx/config/rubber/deploy-sphinx.rb +112 -0
  147. data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/crontab +11 -0
  148. data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf +10 -0
  149. data/generators/vulcanize/templates/sphinx/config/rubber/rubber-sphinx.yml +6 -0
  150. data/generators/vulcanize/templates/sphinx/templates.yml +1 -0
  151. data/generators/vulcanize/vulcanize_generator.rb +67 -0
  152. data/lib/capistrano/hostcmd.rb +12 -0
  153. data/lib/rubber.rb +38 -0
  154. data/lib/rubber/capistrano.rb +1 -0
  155. data/lib/rubber/cloud.rb +13 -0
  156. data/lib/rubber/cloud/aws.rb +334 -0
  157. data/lib/rubber/cloud/base.rb +16 -0
  158. data/lib/rubber/configuration.rb +47 -0
  159. data/lib/rubber/dns.rb +13 -0
  160. data/lib/rubber/dns/base.rb +84 -0
  161. data/lib/rubber/dns/dyndns.rb +78 -0
  162. data/lib/rubber/dns/nettica.rb +117 -0
  163. data/lib/rubber/dns/zerigo.rb +174 -0
  164. data/lib/rubber/environment.rb +169 -0
  165. data/lib/rubber/generator.rb +197 -0
  166. data/lib/rubber/instance.rb +166 -0
  167. data/lib/rubber/recipes/rubber.rb +89 -0
  168. data/lib/rubber/recipes/rubber/bundles.rb +28 -0
  169. data/lib/rubber/recipes/rubber/deploy.rb +90 -0
  170. data/lib/rubber/recipes/rubber/instances.rb +393 -0
  171. data/lib/rubber/recipes/rubber/load_balancers.rb +44 -0
  172. data/lib/rubber/recipes/rubber/security_groups.rb +189 -0
  173. data/lib/rubber/recipes/rubber/setup.rb +457 -0
  174. data/lib/rubber/recipes/rubber/spot_requests.rb +17 -0
  175. data/lib/rubber/recipes/rubber/static_ips.rb +107 -0
  176. data/lib/rubber/recipes/rubber/utils.rb +203 -0
  177. data/lib/rubber/recipes/rubber/volumes.rb +264 -0
  178. data/lib/rubber/tasks/rubber.rb +279 -0
  179. data/lib/rubber/util.rb +37 -0
  180. data/rails/init.rb +9 -0
  181. data/test/environment_test.rb +133 -0
  182. data/test/generator_test.rb +323 -0
  183. data/test/instance_test.rb +93 -0
  184. data/test/test_helper.rb +8 -0
  185. data/test/util_test.rb +16 -0
  186. metadata +298 -0
@@ -0,0 +1,9 @@
1
+ <%
2
+ @read_cmd = 'crontab -l'
3
+ @write_cmd = 'crontab -'
4
+ @additive = ["# rubber-nginx-start", "# rubber-nginx-end"]
5
+ %>
6
+
7
+ # Roll the nginx logs at midnight
8
+ 0 0 * * * LOG_DIR=/mnt/nginx/log <%= RUBBER_ROOT %>/script/cron-rake rubber:rotate_logs
9
+
@@ -0,0 +1,8 @@
1
+ <%
2
+ @path = '/etc/monit/monit.d/monit-nginx.conf'
3
+ %>
4
+ <% PIDFILE = "/var/run/nginx.pid" %>
5
+ check process nginx with pidfile <%= PIDFILE %>
6
+ group nginx-<%= RUBBER_ENV %>
7
+ start program = "/etc/init.d/nginx start"
8
+ stop program = "/etc/init.d/nginx stop"
@@ -0,0 +1,42 @@
1
+ <%
2
+ @path = "/etc/nginx/nginx.conf"
3
+ @post = "mkdir -p /mnt/nginx/logs"
4
+ %>
5
+
6
+ user www-data;
7
+ worker_processes 10;
8
+
9
+ pid /var/run/nginx.pid;
10
+
11
+ events
12
+ {
13
+ worker_connections 1024;
14
+ }
15
+
16
+ http
17
+ {
18
+ include /etc/nginx/mime.types;
19
+ default_type application/octet-stream;
20
+
21
+ sendfile on;
22
+ tcp_nopush on;
23
+ tcp_nodelay off;
24
+
25
+ gzip on;
26
+ gzip_http_version 1.0;
27
+ gzip_comp_level 2;
28
+ gzip_proxied any;
29
+ gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
30
+
31
+ # configure log format like to Apache's "combined" log format
32
+ log_format main
33
+ '$remote_addr - $remote_user [$time_local] '
34
+ '"$request" $status $body_bytes_sent "$http_referer" '
35
+ '"$http_user_agent" "$http_cookie"';
36
+
37
+ # default log files
38
+ error_log /mnt/nginx/logs/error.log notice;
39
+ access_log /mnt/nginx/logs/access.log main;
40
+
41
+ include /etc/nginx/rubber/*.conf;
42
+ }
@@ -0,0 +1,55 @@
1
+ <%
2
+ @path = "/etc/nginx/rubber/tools.conf"
3
+ %>
4
+
5
+
6
+ # This server is setup to serve http.
7
+ server
8
+ {
9
+ listen <%= rubber_env.web_tools_port %>;
10
+ server_name <%= rubber_env.full_host %>;
11
+ root /var/www;
12
+
13
+ rewrite (.*) https://$host:<%= rubber_env.web_tools_ssl_port %>$1 break;
14
+ }
15
+
16
+ # This server is setup to serve https.
17
+ server
18
+ {
19
+ listen <%= rubber_env.web_tools_ssl_port %>;
20
+ server_name <%= rubber_env.full_host %>;
21
+
22
+ ssl on;
23
+ ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
24
+ ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
25
+ # ssl_certificate <%= RUBBER_ROOT %>/config/snapmylife.com.crt;
26
+ # ssl_certificate_key <%= RUBBER_ROOT %>/config/snapmylife.com.key;
27
+
28
+ auth_basic "Rubber Admin Tools";
29
+ auth_basic_user_file <%= RUBBER_ROOT %>/config/<%= rubber_env.app_name %>.auth;
30
+
31
+ client_max_body_size 10M;
32
+ root /var/www;
33
+
34
+
35
+ location /
36
+ {
37
+ # If the file exists as a static file serve it directly without
38
+ # running all the other rewrite tests on it
39
+ if (-f $request_filename)
40
+ {
41
+ break;
42
+ }
43
+
44
+ # check for index.html for directory index
45
+ # if its there on the filesystem then rewite
46
+ # the url to add /index.html to the end of it
47
+ # and then break to send it to the next config rules.
48
+ if (-f $request_filename/index.html)
49
+ {
50
+ rewrite (.*) $1/index.html break;
51
+ }
52
+ }
53
+
54
+ include /etc/nginx/rubber/tools/*.conf;
55
+ }
@@ -0,0 +1,30 @@
1
+ <%
2
+ @path = "/var/www/index.html"
3
+ %>
4
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
5
+ <html>
6
+ <head>
7
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
8
+ <title>Rubber Admin Tools</title>
9
+ </head>
10
+ <body>
11
+ <h1>Rubber Admin Tools</h1>
12
+ <ul>
13
+
14
+ <li><a href="/munin/">Munin</a></li>
15
+
16
+ <% if cruise_host = rubber_instances.for_role('cruise').first %>
17
+ <li><a href="http://<%= cruise_host %>/cruise/">CruiseControl</a></li>
18
+ <% end %>
19
+
20
+ <% rubber_instances.for_role('haproxy').each do |ic| %>
21
+ <li><a href="/haproxy_<%= ic.name %>/">HAProxy <%= ic.name %></a></li>
22
+ <% end %>
23
+
24
+ <% rubber_instances.each do |ic| %>
25
+ <li><a href="/monit_<%= ic.name %>/">Monit <%= ic.name %></a></li>
26
+ <% end %>
27
+
28
+ </ul>
29
+ </body>
30
+ </html>
@@ -0,0 +1,7 @@
1
+ <%
2
+ @path = "#{RUBBER_ROOT}/config/#{rubber_env.app_name}.auth"
3
+ user = rubber_env.web_tools_user || 'admin'
4
+ pass = rubber_env.web_tools_password || rand(1000000000).to_s
5
+ %>
6
+
7
+ <%= user %>:<%= pass.crypt(sprintf('%02d', rand(100)))%>
@@ -0,0 +1,10 @@
1
+
2
+ # Uses from base rubber config
3
+ # domain: foo.com
4
+
5
+ # Uses from rubber-complete.yml
6
+ # web_tools_port: 8080
7
+
8
+ roles:
9
+ nginx:
10
+ packages: [nginx]
@@ -0,0 +1 @@
1
+ description: The nginx module
@@ -0,0 +1,37 @@
1
+
2
+ namespace :rubber do
3
+
4
+ namespace :passenger do
5
+
6
+ rubber.allow_optional_tasks(self)
7
+
8
+ after "rubber:install_gems", "rubber:passenger:custom_install"
9
+
10
+ task :custom_install, :roles => :passenger do
11
+ rubber.sudo_script 'install_passenger', <<-ENDSCRIPT
12
+ if [[ -z `ls #{rubber_env.passenger_lib} 2> /dev/null` ]]; then
13
+ echo -en "\n\n\n\n" | passenger-install-apache2-module
14
+ fi
15
+ ENDSCRIPT
16
+ end
17
+
18
+ after "rubber:setup_app_permissions", "rubber:passenger:setup_passenger_permissions"
19
+
20
+ task :setup_passenger_permissions, :roles => :passenger do
21
+ run "chown #{rubber_env.app_user}:#{rubber_env.app_user} #{current_path}/config/environment.rb"
22
+ end
23
+
24
+ # passenger depends on apache for start/stop/restart, just need these defined
25
+ # as apache hooks into standard deploy lifecycle
26
+
27
+ deploy.task :restart, :roles => :app do
28
+ end
29
+
30
+ deploy.task :stop, :roles => :app do
31
+ end
32
+
33
+ deploy.task :start, :roles => :app do
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,34 @@
1
+ <%
2
+ @path = "/etc/munin/plugins/passenger_memory_status"
3
+ @perms = 0755
4
+ %>#!/usr/bin/env ruby
5
+ # put in /etc/munin/plugins and restart munin-node
6
+ # by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin
7
+ # NOTE: you might need to add munin to allow passwordless sudo for passenger-memory-stats
8
+
9
+ def output_config
10
+ puts <<-END
11
+ graph_category App
12
+ graph_title Passenger memory stats
13
+ graph_vlabel megabytes
14
+
15
+ memory.label memory
16
+ END
17
+ exit 0
18
+ end
19
+
20
+ def output_values
21
+ status = `sudo <%= rubber_env.ruby_prefix %>/bin/passenger-memory-stats | tail -1`
22
+ unless $?.success?
23
+ $stderr.puts "failed executing passenger-memory-stats"
24
+ exit 1
25
+ end
26
+ status =~ /(\d+\.\d+)/
27
+ puts "memory.value #{$1}"
28
+ end
29
+
30
+ if ARGV[0] == "config"
31
+ output_config
32
+ else
33
+ output_values
34
+ end
@@ -0,0 +1,7 @@
1
+ <%
2
+ @path = '/etc/sudoers'
3
+ @additive = ["# munin passenger start", "# munin passenger end"]
4
+ %>
5
+
6
+ nobody ALL=(ALL) NOPASSWD: <%= rubber_env.ruby_prefix %>/bin/passenger-status
7
+ nobody ALL=(ALL) NOPASSWD: <%= rubber_env.ruby_prefix %>/bin/passenger-memory-stats
@@ -0,0 +1,47 @@
1
+ <%
2
+ @path = "/etc/munin/plugins/passenger_status"
3
+ @perms = 0755
4
+ %>#!/usr/bin/env ruby
5
+
6
+ # from http://gist.github.com/21328
7
+ # by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin
8
+
9
+ def output_config
10
+ puts <<-END
11
+ graph_category App
12
+ graph_title passenger status
13
+ graph_vlabel count
14
+
15
+ sessions.label sessions
16
+ max.label max processes
17
+ running.label running processes
18
+ active.label active processes
19
+ END
20
+ exit 0
21
+ end
22
+
23
+ def output_values
24
+ status = `sudo <%= rubber_env.ruby_prefix %>/bin/passenger-status`
25
+ unless $?.success?
26
+ $stderr.puts "failed executing passenger-status"
27
+ exit 1
28
+ end
29
+ status =~ /max\s+=\s+(\d+)/
30
+ puts "max.value #{$1}"
31
+
32
+ status =~ /count\s+=\s+(\d+)/
33
+ puts "running.value #{$1}"
34
+
35
+ status =~ /active\s+=\s+(\d+)/
36
+ puts "active.value #{$1}"
37
+
38
+ total_sessions = 0
39
+ status.scan(/Sessions: (\d+)/).flatten.each { |count| total_sessions += count.to_i }
40
+ puts "sessions.value #{total_sessions}"
41
+ end
42
+
43
+ if ARGV[0] == "config"
44
+ output_config
45
+ else
46
+ output_values
47
+ end
@@ -0,0 +1,46 @@
1
+ <%
2
+ @path = "/etc/apache2/sites-available/#{rubber_env.app_name}-passenger"
3
+ @post = "a2enmod rewrite && a2enmod ssl && a2ensite #{rubber_env.app_name}-passenger"
4
+ %>
5
+
6
+ <% [rubber_env.passenger_listen_port, rubber_env.passenger_listen_ssl_port].each do |port| %>
7
+
8
+ Listen <%= port %>
9
+ <VirtualHost *:<%= port %>>
10
+ ServerName <%= rubber_env.domain %>
11
+ <%- if rubber_env.web_aliases -%>
12
+ ServerAlias <%= rubber_env.web_aliases.join(" ") %>
13
+ <%- end -%>
14
+ DocumentRoot <%= RUBBER_ROOT + "/public" %>
15
+
16
+ ErrorDocument 404 /404.html
17
+ ErrorDocument 500 /500.html
18
+
19
+ SetEnvIf User-Agent "^(.*MSIE.*)|(.*AppleWebKit.*)$" nokeepalive
20
+
21
+ RailsEnv <%= RUBBER_ENV %>
22
+ RailsAllowModRewrite on
23
+
24
+ RewriteEngine On
25
+ RewriteCond %{HTTP_HOST} ^<%= rubber_env.domain %>$
26
+ RewriteRule ^(.*)$ http://www.<%= rubber_env.domain %>$1 [R,L]
27
+
28
+ # Include <%= RUBBER_ROOT %>/config/apache/rewrites.conf
29
+
30
+ RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
31
+ RewriteCond %{SCRIPT_FILENAME} !maintenance.html
32
+ RewriteRule ^.*$ /system/maintenance.html [L]
33
+
34
+ <% if port == rubber_env.passenger_listen_ssl_port %>
35
+ SSLEngine on
36
+ SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
37
+ SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
38
+ SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
39
+ # SSLCertificateFile <%= RUBBER_ROOT %>/config/<%= rubber_env.domain %>.crt
40
+ # SSLCertificateKeyFile <%= RUBBER_ROOT %>/config/<%= rubber_env.domain %>.key
41
+ # SSLCertificateChainFile /etc/ssl/certs/gd_intermediate_bundle.crt
42
+ <% end %>
43
+
44
+ </VirtualHost>
45
+
46
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <%
2
+ @path = '/etc/apache2/mods-available/passenger.conf'
3
+ @post = 'cd /etc/apache2/mods-enabled && ln -fs ../mods-available/passenger.conf'
4
+ %>
5
+ LoadModule passenger_module <%= rubber_env.passenger_lib %>
6
+ PassengerRoot <%= rubber_env.passenger_root %>
7
+ PassengerRuby <%= rubber_env.passenger_ruby %>
8
+ PassengerUseGlobalQueue on
9
+
10
+ PassengerMaxPoolSize <%= rubber_env.max_app_connections %>
@@ -0,0 +1,15 @@
1
+ passenger_version: 2.2.8
2
+ passenger_root: "#{ruby_prefix}/lib/ruby/gems/1.8/gems/passenger-#{passenger_version}"
3
+ passenger_ruby: "#{ruby_prefix}/bin/ruby"
4
+ passenger_lib: "#{passenger_root}/ext/apache2/mod_passenger.so"
5
+ passenger_listen_port: 7000
6
+ passenger_listen_ssl_port: 7001
7
+ max_app_connections: 20
8
+
9
+ role_dependencies:
10
+ passenger: [apache]
11
+
12
+ roles:
13
+ passenger:
14
+ packages: [apache2-mpm-prefork, apache2-prefork-dev]
15
+ gems: [fastthread, rack, [passenger, "#{passenger_version}"]]
@@ -0,0 +1,3 @@
1
+ description: Phusion Passenger module (Apache2)
2
+ dependent_templates:
3
+ - apache
@@ -0,0 +1,36 @@
1
+
2
+ namespace :rubber do
3
+
4
+ namespace :redis do
5
+
6
+ rubber.allow_optional_tasks(self)
7
+
8
+ after "rubber:install_packages", "rubber:redis:custom_install"
9
+
10
+ task :custom_install, :roles => :redis do
11
+ custom_package('http://ftp.us.debian.org/debian/pool/main/r/redis/', 'redis-server', '1.02-1', '! -x /usr/bin/redis-server')
12
+ end
13
+
14
+ desc "Stops the redis server"
15
+ task :stop, :roles => :redis, :on_error => :continue do
16
+ run "/etc/init.d/redis-server stop"
17
+ end
18
+
19
+ desc "Starts the redis server"
20
+ task :start, :roles => :redis do
21
+ run "/etc/init.d/redis-server start"
22
+ end
23
+
24
+ desc "Restarts the redis server"
25
+ task :restart, :roles => :redis do
26
+ run "/etc/init.d/redis-server restart"
27
+ end
28
+
29
+ desc "Reloads the redis server"
30
+ task :reload, :roles => :redis do
31
+ run "/etc/init.d/redis-server restart"
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,8 @@
1
+ <%
2
+ @read_cmd = 'crontab -l'
3
+ @write_cmd = 'crontab -'
4
+ @additive = ['# start-redis-crontab', '# end-redis-crontab']
5
+ %>
6
+
7
+ # backup redis DBs every hour
8
+ 0 * * * * BACKUP_DIR=/mnt/redis_backups BACKUP_NAME=redis BACKUP_CMD="tar -czf \%dir\%/redis_\%time_stamp\%.tgz <%= rubber_env.redis_db_dir %>" <%= RUBBER_ROOT %>/script/cron-rake rubber:backup
@@ -0,0 +1,9 @@
1
+ <%
2
+ @path = '/etc/monit/monit.d/monit-redis.conf'
3
+ %>
4
+ <% PIDFILE = "/var/run/redis.pid" %>
5
+ check process redis with pidfile <%= PIDFILE %>
6
+ group redis-<%= RUBBER_ENV %>
7
+ start program = "/etc/init.d/redis-server start"
8
+ stop program = "/etc/init.d/redis-server stop"
9
+ if failed host <%= rubber_env.host %> port 6379 with timeout 10 seconds for 10 cycles then restart