nirvdrum-rubber 1.1.7 → 2.0.0.rails3.beta6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (291) hide show
  1. data/CHANGELOG +82 -0
  2. data/VERSION +1 -1
  3. data/bin/vulcanize +10 -33
  4. data/generators/vulcanize/templates/apache/config/rubber/deploy-apache.rb +6 -6
  5. data/generators/vulcanize/templates/apache/config/rubber/role/apache/monit-apache.conf +2 -2
  6. data/generators/vulcanize/templates/apache/config/rubber/role/apache/ports.conf +3 -0
  7. data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache-vhost.conf +29 -16
  8. data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-index.html +1 -1
  9. data/generators/vulcanize/templates/base/Rakefile +19 -0
  10. data/generators/vulcanize/templates/base/config/rubber/common/crontab +6 -1
  11. data/generators/vulcanize/templates/base/config/rubber/common/monit-postfix.conf +2 -2
  12. data/generators/vulcanize/templates/base/config/rubber/common/rubber.profile +3 -4
  13. data/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +28 -49
  14. data/generators/vulcanize/templates/base/config/rubber/deploy-util.rb +97 -0
  15. data/generators/vulcanize/templates/base/config/rubber/rubber-dns.yml +0 -1
  16. data/generators/vulcanize/templates/base/config/rubber/rubber-rvm.yml +25 -0
  17. data/generators/vulcanize/templates/base/config/rubber/rubber.yml +21 -13
  18. data/generators/vulcanize/templates/base/script/cron-runner +1 -1
  19. data/generators/vulcanize/templates/base/templates.rb +1 -0
  20. data/generators/vulcanize/templates/base/templates.yml +5 -0
  21. data/generators/vulcanize/templates/cassandra/config/rubber/deploy-cassandra.rb +88 -0
  22. data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.in.sh +58 -0
  23. data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.yaml +210 -0
  24. data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/log4j-server.properties +45 -0
  25. data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/monit-cassandra.conf +8 -0
  26. data/generators/vulcanize/templates/cassandra/config/rubber/rubber-cassandra.yml +18 -0
  27. data/generators/vulcanize/templates/cassandra/templates.yml +1 -0
  28. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/haproxy/haproxy-mongrel.conf +2 -2
  29. data/generators/vulcanize/templates/{complete_passenger_mysql → complete_passenger}/config/rubber/role/haproxy/haproxy-passenger.conf +2 -2
  30. data/generators/vulcanize/templates/complete_passenger/templates.rb +9 -0
  31. data/generators/vulcanize/templates/complete_passenger/templates.yml +9 -0
  32. data/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +1 -7
  33. data/generators/vulcanize/templates/complete_passenger_postgresql/templates.yml +4 -0
  34. data/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +3 -3
  35. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/my.cnf +1 -1
  36. data/generators/vulcanize/templates/haproxy/config/rubber/deploy-haproxy.rb +5 -5
  37. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +2 -2
  38. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf +8 -3
  39. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslogd-default.conf +4 -0
  40. data/generators/vulcanize/templates/jetty/config/rubber/deploy-jetty.rb +5 -5
  41. data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached.conf +1 -1
  42. data/generators/vulcanize/templates/mongrel/config/rubber/deploy-mongrel.rb +4 -4
  43. data/generators/vulcanize/templates/monit/config/rubber/common/monit.conf +2 -1
  44. data/generators/vulcanize/templates/monit/config/rubber/deploy-monit.rb +5 -4
  45. data/generators/vulcanize/templates/munin/config/rubber/common/monit-munin.conf +2 -2
  46. data/generators/vulcanize/templates/munin/config/rubber/common/munin-node.conf +1 -1
  47. data/generators/vulcanize/templates/munin/config/rubber/common/munin-plugins.conf +4 -2
  48. data/generators/vulcanize/templates/munin/config/rubber/deploy-munin.rb +5 -5
  49. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-plugins.conf +1 -1
  50. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +1 -0
  51. data/generators/vulcanize/templates/munin/config/rubber/rubber-munin.yml +1 -1
  52. data/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +6 -8
  53. data/generators/vulcanize/templates/mysql/config/rubber/common/database.yml +1 -0
  54. data/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +40 -27
  55. data/generators/vulcanize/templates/mysql/config/rubber/role/db/apparmor-mysql.conf +46 -0
  56. data/generators/vulcanize/templates/mysql/config/rubber/role/db/monit-mysql.cnf +2 -2
  57. data/generators/vulcanize/templates/mysql/config/rubber/role/db/my.cnf +2 -6
  58. data/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +2 -1
  59. data/generators/vulcanize/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb +19 -15
  60. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf +2 -2
  61. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf +2 -2
  62. data/generators/vulcanize/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb +3 -3
  63. data/generators/vulcanize/templates/nginx/config/rubber/deploy-nginx.rb +5 -5
  64. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/monit-nginx.conf +2 -2
  65. data/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +10 -1
  66. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +1 -1
  67. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +2 -2
  68. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +1 -1
  69. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +28 -3
  70. data/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +3 -3
  71. data/generators/vulcanize/templates/postgresql/config/rubber/common/database.yml +12 -0
  72. data/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +131 -0
  73. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/crontab +14 -0
  74. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/monit-postgresql.conf +10 -0
  75. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/pg_hba.conf +89 -0
  76. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql-sysctl.conf +6 -0
  77. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +504 -0
  78. data/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +45 -0
  79. data/generators/vulcanize/templates/postgresql/templates.yml +1 -0
  80. data/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +8 -7
  81. data/generators/vulcanize/templates/resque/config/initializers/resque.rb +15 -0
  82. data/generators/vulcanize/templates/resque/config/rubber/common/resque.yml +5 -0
  83. data/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +46 -27
  84. data/generators/vulcanize/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf +14 -0
  85. data/generators/vulcanize/templates/resque/config/rubber/role/resque_worker/monit-resque_worker.conf +19 -0
  86. data/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +14 -6
  87. data/generators/vulcanize/templates/resque/script/resque_worker_management.rb +112 -0
  88. data/generators/vulcanize/templates/resque/templates.rb +1 -0
  89. data/generators/vulcanize/templates/sphinx/config/rubber/deploy-sphinx.rb +8 -8
  90. data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf +7 -4
  91. data/generators/vulcanize/vulcanize_generator.rb +139 -49
  92. data/lib/generators/vulcanize/USAGE +6 -0
  93. data/lib/generators/vulcanize/templates/apache/config/rubber/deploy-apache.rb +51 -0
  94. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/deflate.conf +10 -0
  95. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/expires.conf +9 -0
  96. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/headers.conf +6 -0
  97. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/monit-apache.conf +8 -0
  98. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/ports.conf +8 -0
  99. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/setenvif.conf +52 -0
  100. data/lib/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache-vhost.conf +79 -0
  101. data/lib/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache.auth +7 -0
  102. data/lib/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-index.html +34 -0
  103. data/lib/generators/vulcanize/templates/apache/config/rubber/rubber-apache.yml +6 -0
  104. data/lib/generators/vulcanize/templates/apache/templates.yml +1 -0
  105. data/lib/generators/vulcanize/templates/base/Capfile +14 -0
  106. data/lib/generators/vulcanize/templates/base/Rakefile +19 -0
  107. data/lib/generators/vulcanize/templates/base/config/deploy.rb +55 -0
  108. data/lib/generators/vulcanize/templates/base/config/rubber/common/crontab +22 -0
  109. data/lib/generators/vulcanize/templates/base/config/rubber/common/monit-postfix.conf +8 -0
  110. data/lib/generators/vulcanize/templates/base/config/rubber/common/rubber.profile +13 -0
  111. data/lib/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +63 -0
  112. data/lib/generators/vulcanize/templates/base/config/rubber/deploy-util.rb +97 -0
  113. data/lib/generators/vulcanize/templates/base/config/rubber/rubber-dns.yml +78 -0
  114. data/lib/generators/vulcanize/templates/base/config/rubber/rubber-rvm.yml +25 -0
  115. data/lib/generators/vulcanize/templates/base/config/rubber/rubber.yml +235 -0
  116. data/lib/generators/vulcanize/templates/base/lib/tasks/rubber.rake +15 -0
  117. data/lib/generators/vulcanize/templates/base/script/cron-rake +18 -0
  118. data/lib/generators/vulcanize/templates/base/script/cron-runner +18 -0
  119. data/lib/generators/vulcanize/templates/base/script/cron-sh +67 -0
  120. data/lib/generators/vulcanize/templates/base/templates.rb +1 -0
  121. data/lib/generators/vulcanize/templates/base/templates.yml +6 -0
  122. data/lib/generators/vulcanize/templates/cassandra/config/rubber/deploy-cassandra.rb +88 -0
  123. data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.in.sh +58 -0
  124. data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.yaml +210 -0
  125. data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/log4j-server.properties +45 -0
  126. data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/monit-cassandra.conf +8 -0
  127. data/lib/generators/vulcanize/templates/cassandra/config/rubber/rubber-cassandra.yml +18 -0
  128. data/lib/generators/vulcanize/templates/cassandra/templates.yml +1 -0
  129. data/lib/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/haproxy/haproxy-mongrel.conf +23 -0
  130. data/lib/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/nginx/nginx-mongrel.conf +113 -0
  131. data/lib/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/rubber-complete.yml +41 -0
  132. data/lib/generators/vulcanize/templates/complete_mongrel_mysql/templates.yml +6 -0
  133. data/lib/generators/vulcanize/templates/complete_passenger/config/rubber/role/haproxy/haproxy-passenger.conf +21 -0
  134. data/lib/generators/vulcanize/templates/complete_passenger/config/rubber/rubber-complete.yml +40 -0
  135. data/lib/generators/vulcanize/templates/complete_passenger/templates.rb +9 -0
  136. data/lib/generators/vulcanize/templates/complete_passenger/templates.yml +9 -0
  137. data/lib/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +4 -0
  138. data/lib/generators/vulcanize/templates/complete_passenger_postgresql/templates.yml +4 -0
  139. data/lib/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +72 -0
  140. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/cruise +40 -0
  141. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/my.cnf +165 -0
  142. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/production.rb +8 -0
  143. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/site_config.rb +76 -0
  144. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/web_tools/cruise-nginx.conf +11 -0
  145. data/lib/generators/vulcanize/templates/cruise/config/rubber/rubber-cruise.yml +18 -0
  146. data/lib/generators/vulcanize/templates/cruise/templates.yml +1 -0
  147. data/lib/generators/vulcanize/templates/haproxy/config/rubber/deploy-haproxy.rb +45 -0
  148. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-base.conf +26 -0
  149. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-default.conf +8 -0
  150. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +9 -0
  151. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf +11 -0
  152. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslogd-default.conf +21 -0
  153. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/web_tools/haproxy-nginx.conf +10 -0
  154. data/lib/generators/vulcanize/templates/haproxy/config/rubber/rubber-haproxy.yml +7 -0
  155. data/lib/generators/vulcanize/templates/haproxy/templates.yml +1 -0
  156. data/lib/generators/vulcanize/templates/jetty/config/rubber/deploy-jetty.rb +59 -0
  157. data/lib/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.sh +589 -0
  158. data/lib/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.xml +199 -0
  159. data/lib/generators/vulcanize/templates/jetty/config/rubber/role/jetty/monit-jetty.conf +9 -0
  160. data/lib/generators/vulcanize/templates/jetty/config/rubber/rubber-jetty.yml +10 -0
  161. data/lib/generators/vulcanize/templates/jetty/templates.yml +1 -0
  162. data/lib/generators/vulcanize/templates/memcached/config/memcached.yml +28 -0
  163. data/lib/generators/vulcanize/templates/memcached/config/rubber/common/memcached.yml +14 -0
  164. data/lib/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached.conf +52 -0
  165. data/lib/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached_munin_plugin +249 -0
  166. data/lib/generators/vulcanize/templates/memcached/config/rubber/rubber-memcached.yml +7 -0
  167. data/lib/generators/vulcanize/templates/memcached/templates.yml +1 -0
  168. data/lib/generators/vulcanize/templates/minimal_mysql/templates.yml +7 -0
  169. data/lib/generators/vulcanize/templates/minimal_nodb/templates.yml +6 -0
  170. data/lib/generators/vulcanize/templates/mongrel/config/rubber/deploy-mongrel.rb +75 -0
  171. data/lib/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/mongrel_cluster.yml +12 -0
  172. data/lib/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/monit-mongrel.conf +20 -0
  173. data/lib/generators/vulcanize/templates/mongrel/config/rubber/rubber-mongrel.yml +9 -0
  174. data/lib/generators/vulcanize/templates/mongrel/templates.yml +1 -0
  175. data/lib/generators/vulcanize/templates/monit/config/rubber/common/monit-default.conf +15 -0
  176. data/lib/generators/vulcanize/templates/monit/config/rubber/common/monit.conf +252 -0
  177. data/lib/generators/vulcanize/templates/monit/config/rubber/deploy-monit.rb +33 -0
  178. data/lib/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +10 -0
  179. data/lib/generators/vulcanize/templates/monit/config/rubber/rubber-monit.yml +6 -0
  180. data/lib/generators/vulcanize/templates/monit/templates.yml +1 -0
  181. data/lib/generators/vulcanize/templates/munin/config/rubber/common/monit-munin.conf +8 -0
  182. data/lib/generators/vulcanize/templates/munin/config/rubber/common/munin-node.conf +48 -0
  183. data/lib/generators/vulcanize/templates/munin/config/rubber/common/munin-plugins.conf +11 -0
  184. data/lib/generators/vulcanize/templates/munin/config/rubber/deploy-munin.rb +46 -0
  185. data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-nginx.conf +8 -0
  186. data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-plugins.conf +31 -0
  187. data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +81 -0
  188. data/lib/generators/vulcanize/templates/munin/config/rubber/rubber-munin.yml +8 -0
  189. data/lib/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +55 -0
  190. data/lib/generators/vulcanize/templates/munin/script/munin/example_simple.rb +24 -0
  191. data/lib/generators/vulcanize/templates/munin/templates.yml +1 -0
  192. data/lib/generators/vulcanize/templates/mysql/config/rubber/common/database.yml +12 -0
  193. data/lib/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +169 -0
  194. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/apparmor-mysql.conf +46 -0
  195. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/crontab +14 -0
  196. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/monit-mysql.cnf +10 -0
  197. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/my.cnf +163 -0
  198. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/mysql_slave/mysql_slave_munin_plugin +51 -0
  199. data/lib/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +47 -0
  200. data/lib/generators/vulcanize/templates/mysql/templates.yml +1 -0
  201. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/common/mysql_cluster_migrations.rb +13 -0
  202. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb +177 -0
  203. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_data/my.cnf +15 -0
  204. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_mgm/ndb_mgmd.cnf +39 -0
  205. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf +10 -0
  206. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/my.cnf +23 -0
  207. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/rubber-mysql_cluster.yml +32 -0
  208. data/lib/generators/vulcanize/templates/mysql_cluster/templates.yml +1 -0
  209. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/database.yml +16 -0
  210. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf +10 -0
  211. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +153 -0
  212. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.conf +10 -0
  213. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.lua +5 -0
  214. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb +52 -0
  215. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/rubber-mysql_proxy.yml +11 -0
  216. data/lib/generators/vulcanize/templates/mysql_proxy/templates.yml +1 -0
  217. data/lib/generators/vulcanize/templates/nginx/config/rubber/deploy-nginx.rb +45 -0
  218. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/nginx/crontab +9 -0
  219. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/nginx/monit-nginx.conf +8 -0
  220. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/nginx/nginx.conf +42 -0
  221. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
  222. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-index.html +30 -0
  223. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
  224. data/lib/generators/vulcanize/templates/nginx/config/rubber/rubber-nginx.yml +10 -0
  225. data/lib/generators/vulcanize/templates/nginx/templates.yml +1 -0
  226. data/lib/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +46 -0
  227. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +34 -0
  228. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +7 -0
  229. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +47 -0
  230. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf +46 -0
  231. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +35 -0
  232. data/lib/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +15 -0
  233. data/lib/generators/vulcanize/templates/passenger/templates.yml +3 -0
  234. data/lib/generators/vulcanize/templates/postgresql/config/rubber/common/database.yml +12 -0
  235. data/lib/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +131 -0
  236. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/crontab +14 -0
  237. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/monit-postgresql.conf +10 -0
  238. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/pg_hba.conf +89 -0
  239. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql-sysctl.conf +6 -0
  240. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +504 -0
  241. data/lib/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +45 -0
  242. data/lib/generators/vulcanize/templates/postgresql/templates.yml +1 -0
  243. data/lib/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +37 -0
  244. data/lib/generators/vulcanize/templates/redis/config/rubber/role/redis/crontab +8 -0
  245. data/lib/generators/vulcanize/templates/redis/config/rubber/role/redis/monit-redis.conf +9 -0
  246. data/lib/generators/vulcanize/templates/redis/config/rubber/role/redis/redis.conf +141 -0
  247. data/lib/generators/vulcanize/templates/redis/config/rubber/rubber-redis.yml +4 -0
  248. data/lib/generators/vulcanize/templates/redis/templates.yml +1 -0
  249. data/lib/generators/vulcanize/templates/resque/config/initializers/resque.rb +15 -0
  250. data/lib/generators/vulcanize/templates/resque/config/rubber/common/resque.yml +5 -0
  251. data/lib/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +58 -0
  252. data/lib/generators/vulcanize/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf +14 -0
  253. data/lib/generators/vulcanize/templates/resque/config/rubber/role/resque_worker/monit-resque_worker.conf +19 -0
  254. data/lib/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +18 -0
  255. data/lib/generators/vulcanize/templates/resque/script/resque_worker_management.rb +112 -0
  256. data/lib/generators/vulcanize/templates/resque/templates.rb +1 -0
  257. data/lib/generators/vulcanize/templates/resque/templates.yml +3 -0
  258. data/lib/generators/vulcanize/templates/sphinx/config/rubber/common/sphinx.yml +46 -0
  259. data/lib/generators/vulcanize/templates/sphinx/config/rubber/deploy-sphinx.rb +112 -0
  260. data/lib/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/crontab +11 -0
  261. data/lib/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf +13 -0
  262. data/lib/generators/vulcanize/templates/sphinx/config/rubber/rubber-sphinx.yml +6 -0
  263. data/lib/generators/vulcanize/templates/sphinx/templates.yml +1 -0
  264. data/lib/generators/vulcanize/vulcanize_generator.rb +157 -0
  265. data/lib/rubber/cloud/aws.rb +7 -2
  266. data/lib/rubber/dns/zerigo.rb +60 -125
  267. data/lib/rubber/environment.rb +6 -6
  268. data/lib/rubber/generator.rb +33 -25
  269. data/lib/rubber/instance.rb +11 -1
  270. data/lib/rubber/railtie.rb +14 -0
  271. data/lib/rubber/recipes/rubber/deploy.rb +3 -3
  272. data/lib/rubber/recipes/rubber/instances.rb +12 -1
  273. data/lib/rubber/recipes/rubber/setup.rb +96 -55
  274. data/lib/rubber/recipes/rubber/spot_requests.rb +6 -0
  275. data/lib/rubber/recipes/rubber/static_ips.rb +83 -0
  276. data/lib/rubber/recipes/rubber/utils.rb +39 -16
  277. data/lib/rubber/recipes/rubber/volumes.rb +4 -4
  278. data/lib/rubber/recipes/rubber.rb +16 -9
  279. data/lib/rubber/util.rb +28 -1
  280. data/lib/rubber.rb +47 -7
  281. data/rails/init.rb +1 -4
  282. data/test/environment_test.rb +3 -0
  283. data/test/generator_test.rb +47 -0
  284. data/test/instance_test.rb +3 -0
  285. data/test/test_helper.rb +6 -0
  286. data/test/util_test.rb +3 -0
  287. data/test/zerigo_test.rb +87 -0
  288. metadata +275 -50
  289. data/generators/vulcanize/templates/resque/config/rubber/deploy-resque-worker-default.rb +0 -38
  290. data/generators/vulcanize/templates/resque/config/rubber/role/resque_worker_default/monit-resque_worker_default.conf +0 -19
  291. /data/generators/vulcanize/templates/{complete_passenger_mysql → complete_passenger}/config/rubber/rubber-complete.yml +0 -0
@@ -4,36 +4,55 @@ namespace :rubber do
4
4
  namespace :resque do
5
5
 
6
6
  rubber.allow_optional_tasks(self)
7
-
8
- after "rubber:install_packages", "rubber:resque:custom_install"
9
-
10
- task :custom_install, :roles => :resque do
11
- rubber.sudo_script 'install_resque', <<-ENDSCRIPT
12
- if [ -d resque ]; then
13
- rm -r resque
14
- fi
15
-
16
- git clone git://github.com/defunkt/resque.git
17
-
18
- if [ -d #{rubber_env.resque_web_dir} ]; then
19
- rm -r #{rubber_env.resque_web_dir}
20
- fi
21
-
22
- mkdir -p #{rubber_env.resque_web_dir}
23
- mkdir #{rubber_env.resque_web_dir}/tmp
24
- mv resque/config.ru #{rubber_env.resque_web_dir}
25
- mv resque/lib/resque/server/* #{rubber_env.resque_web_dir}/
26
-
27
- rm -f /var/www/resque
28
- ln -s #{rubber_env.resque_web_dir}/public /var/www/resque
29
- ENDSCRIPT
7
+
8
+ namespace :worker do
9
+
10
+ rubber.allow_optional_tasks(self)
11
+
12
+ before "deploy:stop", "rubber:resque:worker:stop"
13
+ after "deploy:start", "rubber:resque:worker:start"
14
+ after "deploy:restart", "rubber:resque:worker:restart"
15
+
16
+ desc "Starts resque workers"
17
+ task :start, :roles => :resque_worker do
18
+ rsudo "cd #{current_path} && RUBBER_ENV=#{rails_env} ./script/resque_worker_management.rb start", :as => rubber_env.app_user
19
+ end
20
+
21
+ desc "Stops resque workers"
22
+ task :stop, :roles => :resque_worker do
23
+ rsudo "cd #{current_path} && RUBBER_ENV=#{rails_env} ./script/resque_worker_management.rb stop", :as => rubber_env.app_user
24
+ end
25
+
26
+ desc "Restarts resque workers"
27
+ task :restart, :roles => :resque_worker do
28
+ rsudo "cd #{current_path} && RUBBER_ENV=#{rails_env} ./script/resque_worker_management.rb restart", :as => rubber_env.app_user
29
+ end
30
30
  end
31
31
 
32
- after "rubber:setup_app_permissions", "rubber:resque:setup_resque_permissions"
32
+ namespace :web do
33
+ rubber.allow_optional_tasks(self)
34
+
35
+ before "deploy:stop", "rubber:resque:web:stop"
36
+ after "deploy:start", "rubber:resque:web:start"
37
+ after "deploy:restart", "rubber:resque:web:restart"
38
+
39
+ desc "Starts resque web tools"
40
+ task :start, :roles => :resque_web do
41
+ rsudo "RAILS_ENV=#{RUBBER_ENV} resque-web --pid-file /var/run/resque_web.pid --port #{rubber_env.resque_web_port} --no-launch #{current_path}/config/initializers/resque.rb"
42
+ end
43
+
44
+ desc "Stops resque web tools"
45
+ task :stop, :roles => :resque_web do
46
+ rsudo "RAILS_ENV=#{RUBBER_ENV} resque-web --pid-file /var/run/resque_web.pid --kill"
47
+ end
48
+
49
+ desc "Restarts resque web tools"
50
+ task :restart, :roles => :resque_web do
51
+ rubber.resque.web.stop
52
+ rubber.resque.web.start
53
+ end
33
54
 
34
- task :setup_resque_permissions, :roles => :resque do
35
- run "chown -R #{rubber_env.app_user}:#{rubber_env.app_user} #{rubber_env.resque_web_dir}/config.ru"
36
55
  end
37
-
56
+
38
57
  end
39
58
  end
@@ -0,0 +1,14 @@
1
+ <%
2
+ @path = '/etc/monit/monit.d/monit-resque_web.conf'
3
+
4
+ PIDFILE = "/var/run/resque_web.pid"
5
+ start_program = "HOME=/root resque-web --pid-file #{PIDFILE} --port #{rubber_env.resque_web_port} --no-launch #{RUBBER_ROOT}/config/initializers/resque.rb"
6
+ stop_program = "HOME=/root resque-web --pid-file #{PIDFILE} --kill"
7
+ %>
8
+
9
+ check process resque_web with pidfile <%= PIDFILE %>
10
+ group resque_web
11
+ start program = "bash -l -c '<%= start_program %>'"
12
+ stop program = "bash -l -c '<%= stop_program %>'"
13
+
14
+ if totalmem > 350.0 MB for 15 cycles then restart
@@ -0,0 +1,19 @@
1
+ <%
2
+ @path = '/etc/monit/monit.d/monit-resque_worker.conf'
3
+ %>
4
+
5
+ <% rubber_env.resque_workers.each_with_index do |worker, i| %>
6
+ <%
7
+ PIDFILE = "#{RUBBER_ROOT}/tmp/pids/resque_worker_#{i}.pid"
8
+
9
+ start_program = "cd #{RUBBER_ROOT} && ./script/resque_worker_management.rb start #{i}"
10
+ stop_program = "cd #{RUBBER_ROOT} && ./script/resque_worker_management.rb stop #{i}"
11
+ %>
12
+
13
+ check process resque_worker_<%= i %> with pidfile <%= PIDFILE %>
14
+ group resque_worker
15
+ start program = "/usr/bin/sudo -H -u <%= rubber_env.app_user %> bash -l -c '<%= start_program %>'"
16
+ stop program = "/usr/bin/sudo -H -u <%= rubber_env.app_user %> bash -l -c '<%= stop_program %>'"
17
+
18
+ if totalmem > 350.0 MB for 15 cycles then restart
19
+ <% end %>
@@ -1,10 +1,18 @@
1
- resque_web_dir: /opt/resque
1
+ resque_web_port: 5678
2
2
 
3
- resque_worker_default_count: 5
3
+ # list of workers with the queues to be run on each - on each worker instance,
4
+ # a worker is run for each item in this list to handle the queues specified
5
+ #
6
+ resque_workers:
7
+ -
8
+ queues: *
9
+ poll_interval: 1
10
+ -
11
+ queues: *
12
+ poll_interval: 1
13
+
14
+ gems: [yajl-ruby resque]
4
15
 
5
16
  role_dependencies:
6
- css_validator: [redis]
17
+ web_tools: [resque_web]
7
18
 
8
- roles:
9
- resque:
10
- gems: [redis redis-namespace yajl-ruby sinatra resque]
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ env = ENV["RUBBER_ENV"] ||= "development"
4
+ root = File.join(File.dirname(__FILE__), '..')
5
+ rails_env_file = File.join(root, 'config', 'environment.rb')
6
+
7
+ if File.exists? rails_env_file
8
+ require(rails_env_file)
9
+ else
10
+ require "rubber"
11
+ Rubber::initialize(root, env)
12
+ require 'resque'
13
+ require "#{root}/config/initializers/resque.rb"
14
+ end
15
+
16
+ def start_all(workers)
17
+ puts "Starting all workers"
18
+ workers.each_with_index do |worker, i|
19
+ start(worker, i)
20
+ end
21
+ end
22
+
23
+ def start(worker, index)
24
+ puts "Starting worker #{index}/#{worker.queues}"
25
+
26
+ log_file = log_file(index)
27
+ pid_file = pid_file(index)
28
+
29
+ queues = worker.queues.to_s.split(',')
30
+
31
+ daemonize(log_file, pid_file) do
32
+ resque_worker = Resque::Worker.new(*queues)
33
+ resque_worker.verbose = ENV['LOGGING'] || ENV['VERBOSE']
34
+ resque_worker.very_verbose = ENV['VVERBOSE']
35
+
36
+ puts "*** Starting worker #{resque_worker}"
37
+ resque_worker.work(worker.poll_interval.to_i || 5) # interval, will block
38
+ end
39
+ end
40
+
41
+ def stop_all(workers)
42
+ puts "Stopping all workers"
43
+ workers.size.times do |i|
44
+ stop(i)
45
+ end
46
+ end
47
+
48
+ def stop(index)
49
+ puts "Stopping worker #{index}"
50
+
51
+ pid_file = pid_file(index)
52
+ pid = File.read(pid_file).to_i rescue nil
53
+ if pid
54
+ puts "Killing worker #{index}: pid #{pid}"
55
+ begin
56
+ Process.kill("QUIT", pid)
57
+ rescue Exception => e
58
+ puts e
59
+ end
60
+ File.delete(pid_file) if File.exist?(pid_file)
61
+ else
62
+ puts "No pid file for worker #{index}: #{pid_file}"
63
+ end
64
+ end
65
+
66
+ def daemonize(log_file, pid_file)
67
+ return if fork
68
+ Process::setsid
69
+ exit!(0) if fork
70
+ Dir::chdir("/")
71
+ File.umask 0000
72
+ FileUtils.touch log_file
73
+ STDIN.reopen log_file
74
+ STDOUT.reopen log_file, "a"
75
+ STDERR.reopen log_file, "a"
76
+
77
+ File.open(pid_file, 'w') {|f| f.write("#{Process.pid}") }
78
+
79
+ yield if block_given?
80
+ exit(0)
81
+ end
82
+
83
+ def pid_file(index)
84
+ File.expand_path "#{Rubber.root}/tmp/pids/resque_worker_#{index}.pid"
85
+ end
86
+
87
+ def log_file(index)
88
+ File.expand_path "#{Rubber.root}/log/resque_worker_#{index}.log"
89
+ end
90
+
91
+ action = ARGV[0]
92
+ worker_index = ARGV[1] ? ARGV[1].to_i : nil
93
+ if action.nil? || ! %w[start stop restart].include?(action)
94
+ puts "Usage: script/resque_worker_management.rb [start|stop|restart]"
95
+ end
96
+
97
+ workers = Rubber.config.resque_workers
98
+
99
+ case action
100
+ when 'start'
101
+ worker_index ? start(workers[worker_index], worker_index) : start_all(workers)
102
+ when 'stop'
103
+ worker_index ? stop(worker_index) : stop_all(workers)
104
+ when 'restart'
105
+ if worker_index
106
+ stop(worker_index)
107
+ start(workers[worker_index], worker_index)
108
+ else
109
+ stop_all(workers)
110
+ start_all(workers)
111
+ end
112
+ end
@@ -0,0 +1 @@
1
+ gem "resque"if Rubber::Util::is_bundler?
@@ -18,7 +18,7 @@ namespace :rubber do
18
18
  task :custom_install, :roles => :sphinx do
19
19
  # install sphinx from source
20
20
  ver = "0.9.8.1"
21
- rubber.run_script 'install_sphinx', <<-ENDSCRIPT
21
+ rubber.sudo_script 'install_sphinx', <<-ENDSCRIPT
22
22
  # check if already installed
23
23
  if [ -x /usr/local/bin/searchd ]
24
24
  then echo 'Found sphinx searchd on system'
@@ -60,25 +60,25 @@ namespace :rubber do
60
60
  desc "Do sphinx setup tasks"
61
61
  task :setup, :roles => :sphinx do
62
62
  # Setup links to sphinx config/index as they need to persist between deploys
63
- run "mkdir -p #{sphinx_root} #{sphinx_root}/config #{sphinx_root}/db"
64
- run "chown -R #{runner}:#{runner} #{sphinx_root}"
63
+ rsudo "mkdir -p #{sphinx_root} #{sphinx_root}/config #{sphinx_root}/db"
64
+ rsudo "chown -R #{runner}:#{runner} #{sphinx_root}"
65
65
  end
66
66
 
67
67
  desc "Setup paths for sphinx runtime"
68
68
  task :config_dir, :roles => :sphinx do
69
- run "rm -rf #{current_path}/sphinx && ln -sf #{sphinx_root} #{current_path}/sphinx"
69
+ rsudo "rm -rf #{current_path}/sphinx"
70
+ rsudo "ln -sf #{sphinx_root} #{current_path}/sphinx"
70
71
  end
71
72
 
72
73
  # runs the given ultrasphinx rake tasks
73
74
  def run_sphinx task
74
- cmd = "cd #{current_path} && sudo -u #{runner} RAILS_ENV=#{RUBBER_ENV} rake #{task}"
75
- run cmd
75
+ rsudo "cd #{current_path} && RAILS_ENV=#{RUBBER_ENV} rake #{task}", :as => runner
76
76
  end
77
77
 
78
78
 
79
79
  desc "Stops sphinx searchd"
80
- task :stop, :roles => :sphinx, :on_error => :continue do
81
- run_sphinx 'ts:stop'
80
+ task :stop, :roles => :sphinx do
81
+ run_sphinx 'ts:stop; exit 0'
82
82
  end
83
83
 
84
84
  desc "Starts sphinx searchd"
@@ -1,10 +1,13 @@
1
1
  <%
2
2
  @path = '/etc/monit/monit.d/monit-sphinx.conf'
3
+
4
+ PIDFILE = "#{RUBBER_ROOT}/log/searchd.#{RUBBER_ENV}.pid"
5
+ start_program = "cd #{RUBBER_ROOT} && rake ts:start"
6
+ stop_program = "cd #{RUBBER_ROOT} && rake ts:stop"
3
7
  %>
4
8
 
5
- check process sphinx with pidfile <%= RUBBER_ROOT %>/log/searchd.<%= RUBBER_ENV %>.pid
9
+ check process sphinx with pidfile <%= PIDFILE %>
6
10
  group sphinx-<%= RUBBER_ENV %>
7
- start program = "/usr/bin/sudo -u rails sh -c 'cd <%= RUBBER_ROOT %> && PATH=<%= rubber_env.ruby_prefix %>/bin:/usr/local/bin:$PATH RAILS_ENV=<%= RUBBER_ENV %> rake ts:start'"
8
- stop program = "/usr/bin/sudo -u rails sh -c 'cd <%= RUBBER_ROOT %> && PATH=<%= rubber_env.ruby_prefix %>/bin:/usr/local/bin:$PATH RAILS_ENV=<%= RUBBER_ENV %> rake ts:stop'"
11
+ start program = "/usr/bin/sudo -H -u <%= rubber_env.app_user %> bash -l -c '<%= start_program %>'"
12
+ stop program = "/usr/bin/sudo -H -u <%= rubber_env.app_user %> bash -l -c '<%= stop_program %>'"
9
13
  if failed host <%= rubber_env.host %> port 3312 with timeout 5 seconds for 5 cycles then restart
10
-
@@ -1,67 +1,157 @@
1
- require 'fileutils'
2
1
  require 'find'
2
+ require 'yaml'
3
+
4
+ if defined?(Rails) && Rails::VERSION::MAJOR == 2
5
+ require 'fileutils'
6
+ require 'commands/generate'
7
+
8
+ class VulcanizeGenerator < Rails::Generator::NamedBase
9
+
10
+ TEMPLATE_ROOT = File.dirname(__FILE__) + "/templates" unless defined?(TEMPLATE_ROOT)
11
+ TEMPLATE_FILE = "templates.yml" unless defined?(TEMPLATE_FILE)
12
+
13
+ def manifest
14
+ record do |m|
15
+ templates = [file_name] + actions
16
+ templates.each do |t|
17
+ apply_template(m, t)
18
+ end
19
+ end
20
+ end
21
+
22
+ def apply_template(m, name)
23
+ sp = source_path("#{name}/")
24
+ unless File.directory?(sp)
25
+ raise Rails::Generator::UsageError.new("Invalid template #{name}, use one of #{valid_templates.join(', ')}")
26
+ end
27
+
28
+ templ_conf = load_template_config(sp)
29
+ deps = templ_conf['dependent_templates'] || []
30
+ deps.each do |dep|
31
+ apply_template(m, dep)
32
+ end
33
+
34
+ Find.find(sp) do |f|
35
+ Find.prune if File.basename(f) =~ /^(CVS|\.svn)$/
36
+ Find.prune if f == "#{sp}#{TEMPLATE_FILE}"
37
+
38
+ rel = f.gsub(/#{source_root}\//, '')
39
+ dest_rel = rel.gsub(/^#{name}\//, '')
40
+ m.directory(dest_rel) if File.directory?(f)
41
+ if File.file?(f)
42
+ # force scripts to be executable
43
+ opts = (File.read(f) =~ /^#!/) ? {:chmod => 0755} : {}
44
+ m.file(rel, dest_rel, opts)
45
+ end
3
46
 
4
- class VulcanizeGenerator < Rails::Generator::NamedBase
5
-
6
- TEMPLATE_ROOT = File.dirname(__FILE__) + "/templates"
7
- TEMPLATE_FILE = "templates.yml"
8
-
9
- def manifest
10
- record do |m|
11
- templates = [file_name] + actions
12
- templates.each do |t|
13
- apply_template(m, t)
14
47
  end
15
48
  end
49
+
50
+ protected
51
+ def valid_templates
52
+ valid = Dir.entries(TEMPLATE_ROOT).delete_if {|e| e =~ /(^\.)|svn|CVS/ }
53
+ end
54
+
55
+ def load_template_config(template_dir)
56
+ templ_file = "#{template_dir}/templates.yml"
57
+ templ_conf = YAML.load(File.read(templ_file)) rescue {}
58
+ return templ_conf
59
+ end
60
+
61
+ def banner
62
+ usage = "Usage: #{$0} vulcanize template_name ...\n"
63
+ usage << "where template_name is one of:\n\n"
64
+ valid_templates.each do |t|
65
+ templ_conf = load_template_config("#{TEMPLATE_ROOT}/#{t}")
66
+ desc = templ_conf['description']
67
+ usage << " #{t}: #{desc}\n"
68
+ end
69
+ return usage
70
+ end
16
71
  end
17
72
 
18
- def apply_template(m, name)
19
- sp = source_path("#{name}/")
20
- unless File.directory?(sp)
21
- raise Rails::Generator::UsageError.new("Invalid template #{name}, use one of #{valid_templates.join(', ')}")
73
+ else
74
+ require 'rails/generators'
75
+
76
+ class VulcanizeGenerator < Rails::Generators::NamedBase
77
+
78
+ def self.source_root
79
+ File.join(File.dirname(__FILE__), 'templates')
22
80
  end
23
-
24
- templ_conf = load_template_config(sp)
25
- deps = templ_conf['dependent_templates'] || []
26
- deps.each do |dep|
27
- apply_template(m, dep)
81
+
82
+ def copy_template_files
83
+ @template_dependencies = find_dependencies(file_name)
84
+ ([file_name] + @template_dependencies).each do |template|
85
+ apply_template(template)
86
+ end
28
87
  end
29
-
30
- Find.find(sp) do |f|
31
- Find.prune if File.basename(f) =~ /^(CVS|\.svn)$/
32
- Find.prune if f == "#{sp}#{TEMPLATE_FILE}"
33
-
34
- rel = f.gsub(/#{source_root}\//, '')
35
- dest_rel = rel.gsub(/^#{name}\//, '')
36
- m.directory(dest_rel) if File.directory?(f)
37
- if File.file?(f)
38
- # force scripts to be executable
39
- opts = (File.read(f) =~ /^#!/) ? {:chmod => 0755} : {}
40
- m.file(rel, dest_rel, opts)
88
+
89
+ protected
90
+
91
+ # helper to test for rails for optional templates
92
+ def rails?
93
+ Rubber::Util::is_rails?
94
+ end
95
+
96
+ def find_dependencies(name)
97
+ template_dir = File.join(self.class.source_root, name, '')
98
+ unless File.directory?(template_dir)
99
+ raise Rails::Generators::Error.new("Invalid template #{name}, use one of #{valid_templates.join(', ')}")
100
+ end
101
+
102
+ template_conf = load_template_config(template_dir)
103
+ template_dependencies = template_conf['dependent_templates'] || []
104
+
105
+ template_dependencies.clone.each do |dep|
106
+ template_dependencies.concat(find_dependencies(dep))
41
107
  end
42
108
 
109
+ return template_dependencies.uniq
110
+ end
111
+
112
+ def apply_template(name)
113
+ template_dir = File.join(self.class.source_root, name, '')
114
+ unless File.directory?(template_dir)
115
+ raise Rails::Generators::Error.new("Invalid template #{name}, use one of #{valid_templates.join(', ')}")
116
+ end
117
+
118
+ template_conf = load_template_config(template_dir)
119
+
120
+ extra_generator_steps_file = File.join(template_dir, 'templates.rb')
121
+ if File.exist? extra_generator_steps_file
122
+ eval File.read(extra_generator_steps_file), binding, extra_generator_steps_file
123
+ end
124
+
125
+ Find.find(template_dir) do |f|
126
+ Find.prune if f == File.join(template_dir, 'templates.yml') # don't copy over templates.yml
127
+ Find.prune if f == extra_generator_steps_file # don't copy over templates.rb
128
+
129
+ template_rel = f.gsub(/#{template_dir}/, '')
130
+ source_rel = f.gsub(/#{self.class.source_root}\//, '')
131
+ dest_rel = source_rel.gsub(/^#{name}\//, '')
132
+
133
+ # Only include optional files when their conditions eval to true
134
+ optional = template_conf['optional'][template_rel] rescue nil
135
+ Find.prune if optional && ! eval(optional)
136
+
137
+ if File.directory?(f)
138
+ empty_directory(dest_rel)
139
+ else
140
+ copy_file(source_rel, dest_rel)
141
+ src_mode = File.stat(f).mode
142
+ dest_mode = File.stat(File.join(destination_root, dest_rel)).mode
143
+ chmod(dest_rel, src_mode) if src_mode != dest_mode
144
+ end
145
+ end
43
146
  end
44
- end
45
147
 
46
- protected
47
148
  def valid_templates
48
- valid = Dir.entries(TEMPLATE_ROOT).delete_if {|e| e =~ /(^\.)|svn|CVS/ }
149
+ valid = Dir.entries(self.class.source_root).delete_if {|e| e =~ /(^\.)|svn|CVS/ }
49
150
  end
50
-
151
+
51
152
  def load_template_config(template_dir)
52
- templ_file = "#{template_dir}/templates.yml"
53
- templ_conf = YAML.load(File.read(templ_file)) rescue {}
54
- return templ_conf
153
+ YAML.load(File.read(File.join(template_dir, 'templates.yml'))) rescue {}
55
154
  end
155
+ end
56
156
 
57
- def banner
58
- usage = "Usage: #{$0} vulcanize template_name ...\n"
59
- usage << "where template_name is one of:\n\n"
60
- valid_templates.each do |t|
61
- templ_conf = load_template_config("#{TEMPLATE_ROOT}/#{t}")
62
- desc = templ_conf['description']
63
- usage << " #{t}: #{desc}\n"
64
- end
65
- return usage
66
- end
67
157
  end
@@ -0,0 +1,6 @@
1
+ Description:
2
+ Prepares the rails application for deploying with rubber by installing a
3
+ sample rubber configuration template
4
+
5
+ Examples:
6
+ ./script/generate vulcanize minimal_mysql
@@ -0,0 +1,51 @@
1
+
2
+ namespace :rubber do
3
+
4
+ namespace :apache do
5
+
6
+ rubber.allow_optional_tasks(self)
7
+
8
+ after "rubber:install_packages", "rubber:apache:custom_install"
9
+
10
+ task :custom_install, :roles => :apache do
11
+ rsudo "a2dissite default"
12
+ end
13
+
14
+ # serial_task can only be called after roles defined - not normally a problem, but
15
+ # rubber auto-roles don't get defined till after all tasks are defined
16
+ on :load do
17
+ rubber.serial_task self, :serial_restart, :roles => :apache do
18
+ rsudo "service apache2 restart"
19
+ end
20
+ rubber.serial_task self, :serial_reload, :roles => :apache do
21
+ rsudo "if ! ps ax | grep -v grep | grep -c apache2 &> /dev/null; then service apache2 start; else service apache2 reload; fi"
22
+ end
23
+ end
24
+
25
+ before "deploy:stop", "rubber:apache:stop"
26
+ after "deploy:start", "rubber:apache:start"
27
+ after "deploy:restart", "rubber:apache:reload"
28
+
29
+ desc "Stops the apache web server"
30
+ task :stop, :roles => :apache do
31
+ rsudo "service apache2 stop; exit 0"
32
+ end
33
+
34
+ desc "Starts the apache web server"
35
+ task :start, :roles => :apache do
36
+ rsudo "service apache2 start"
37
+ end
38
+
39
+ desc "Restarts the apache web server"
40
+ task :restart, :roles => :apache do
41
+ serial_restart
42
+ end
43
+
44
+ desc "Reloads the apache web server"
45
+ task :reload, :roles => :apache do
46
+ serial_reload
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,10 @@
1
+ <%
2
+ @path = "/etc/apache2/mods-available/deflate.conf"
3
+ @post = "a2enmod deflate"
4
+ %>
5
+ <IfModule mod_deflate.c>
6
+ SetOutputFilter DEFLATE
7
+ BrowserMatch ^Mozilla/4 gzip-only-text/html
8
+ BrowserMatch ^Mozilla/4.0[678] no-gzip
9
+ BrowserMatch bMSIE !no-gzip !gzip-only-text/html
10
+ </IfModule>
@@ -0,0 +1,9 @@
1
+ <%
2
+ @path = "/etc/apache2/mods-available/expires.conf"
3
+ @post = "a2enmod expires"
4
+ %>
5
+ ExpiresActive On
6
+ <FilesMatch "\.(ico|gif|jpe?g|png|js|css)$">
7
+ ExpiresDefault "access plus 1 year"
8
+ </FilesMatch>
9
+
@@ -0,0 +1,6 @@
1
+ <%
2
+ @path = "/etc/apache2/mods-available/headers.conf"
3
+ @post = "a2enmod headers"
4
+ %>
5
+ # Make sure proxies don't deliver the wrong content
6
+ Header append Vary User-Agent env=!dont-vary
@@ -0,0 +1,8 @@
1
+ <%
2
+ @path = '/etc/monit/monit.d/monit-apache.conf'
3
+ %>
4
+ <% PIDFILE = "/var/run/apache2.pid" %>
5
+ check process apache with pidfile <%= PIDFILE %>
6
+ group apache-<%= RUBBER_ENV %>
7
+ start program = "/usr/sbin/service apache2 start"
8
+ stop program = "/usr/sbin/service apache2 stop"
@@ -0,0 +1,8 @@
1
+ <%
2
+ @path = '/etc/apache2/ports.conf'
3
+ # need to stop here so that apache will release port 80 before other
4
+ # services start and need to bind to it (e.g. haproxy)
5
+ @post = 'service apache2 stop'
6
+ %>
7
+ # empty ports file since other modules contribute which ports to open (vhosts)
8
+