nogara-rubber 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (389) hide show
  1. data/CHANGELOG +448 -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 +25 -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 +8 -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 +79 -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/Rakefile +23 -0
  22. data/generators/vulcanize/templates/base/config/deploy.rb +56 -0
  23. data/generators/vulcanize/templates/base/config/rubber/common/crontab +22 -0
  24. data/generators/vulcanize/templates/base/config/rubber/common/monit-postfix.conf +8 -0
  25. data/generators/vulcanize/templates/base/config/rubber/common/rubber.profile +13 -0
  26. data/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +92 -0
  27. data/generators/vulcanize/templates/base/config/rubber/deploy-util.rb +97 -0
  28. data/generators/vulcanize/templates/base/config/rubber/rubber-dns.yml +78 -0
  29. data/generators/vulcanize/templates/base/config/rubber/rubber-rvm.yml +33 -0
  30. data/generators/vulcanize/templates/base/config/rubber/rubber.yml +233 -0
  31. data/generators/vulcanize/templates/base/lib/tasks/rubber.rake +15 -0
  32. data/generators/vulcanize/templates/base/script/cron-rake +18 -0
  33. data/generators/vulcanize/templates/base/script/cron-runner +18 -0
  34. data/generators/vulcanize/templates/base/script/cron-sh +67 -0
  35. data/generators/vulcanize/templates/base/templates.rb +11 -0
  36. data/generators/vulcanize/templates/base/templates.yml +6 -0
  37. data/generators/vulcanize/templates/cassandra/config/rubber/deploy-cassandra.rb +88 -0
  38. data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.in.sh +60 -0
  39. data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.yaml +210 -0
  40. data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/log4j-server.properties +45 -0
  41. data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/monit-cassandra.conf +8 -0
  42. data/generators/vulcanize/templates/cassandra/config/rubber/rubber-cassandra.yml +18 -0
  43. data/generators/vulcanize/templates/cassandra/templates.yml +1 -0
  44. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/haproxy/haproxy-mongrel.conf +23 -0
  45. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/nginx/nginx-mongrel.conf +113 -0
  46. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/rubber-complete.yml +41 -0
  47. data/generators/vulcanize/templates/complete_mongrel_mysql/templates.yml +6 -0
  48. data/generators/vulcanize/templates/complete_passenger/config/rubber/role/haproxy/haproxy-passenger.conf +21 -0
  49. data/generators/vulcanize/templates/complete_passenger/config/rubber/rubber-complete.yml +40 -0
  50. data/generators/vulcanize/templates/complete_passenger/templates.rb +9 -0
  51. data/generators/vulcanize/templates/complete_passenger/templates.yml +9 -0
  52. data/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +4 -0
  53. data/generators/vulcanize/templates/complete_passenger_postgresql/templates.yml +4 -0
  54. data/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +72 -0
  55. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/cruise +40 -0
  56. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/my.cnf +165 -0
  57. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/production.rb +8 -0
  58. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/site_config.rb +76 -0
  59. data/generators/vulcanize/templates/cruise/config/rubber/role/web_tools/cruise-nginx.conf +11 -0
  60. data/generators/vulcanize/templates/cruise/config/rubber/rubber-cruise.yml +18 -0
  61. data/generators/vulcanize/templates/cruise/templates.yml +1 -0
  62. data/generators/vulcanize/templates/haproxy/config/rubber/deploy-haproxy.rb +45 -0
  63. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-base.conf +26 -0
  64. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-default.conf +8 -0
  65. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +9 -0
  66. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf +11 -0
  67. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslogd-default.conf +21 -0
  68. data/generators/vulcanize/templates/haproxy/config/rubber/role/web_tools/haproxy-nginx.conf +10 -0
  69. data/generators/vulcanize/templates/haproxy/config/rubber/rubber-haproxy.yml +7 -0
  70. data/generators/vulcanize/templates/haproxy/templates.yml +1 -0
  71. data/generators/vulcanize/templates/jetty/config/rubber/deploy-jetty.rb +59 -0
  72. data/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.sh +589 -0
  73. data/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.xml +199 -0
  74. data/generators/vulcanize/templates/jetty/config/rubber/role/jetty/monit-jetty.conf +9 -0
  75. data/generators/vulcanize/templates/jetty/config/rubber/rubber-jetty.yml +10 -0
  76. data/generators/vulcanize/templates/jetty/templates.yml +1 -0
  77. data/generators/vulcanize/templates/memcached/config/memcached.yml +28 -0
  78. data/generators/vulcanize/templates/memcached/config/rubber/common/memcached.yml +14 -0
  79. data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached.conf +52 -0
  80. data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached_munin_plugin +249 -0
  81. data/generators/vulcanize/templates/memcached/config/rubber/rubber-memcached.yml +7 -0
  82. data/generators/vulcanize/templates/memcached/templates.yml +1 -0
  83. data/generators/vulcanize/templates/minimal_mysql/templates.yml +7 -0
  84. data/generators/vulcanize/templates/minimal_nodb/templates.yml +6 -0
  85. data/generators/vulcanize/templates/mongrel/config/rubber/deploy-mongrel.rb +75 -0
  86. data/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/mongrel_cluster.yml +12 -0
  87. data/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/monit-mongrel.conf +20 -0
  88. data/generators/vulcanize/templates/mongrel/config/rubber/rubber-mongrel.yml +9 -0
  89. data/generators/vulcanize/templates/mongrel/templates.yml +1 -0
  90. data/generators/vulcanize/templates/monit/config/rubber/common/monit-default.conf +15 -0
  91. data/generators/vulcanize/templates/monit/config/rubber/common/monit.conf +252 -0
  92. data/generators/vulcanize/templates/monit/config/rubber/deploy-monit.rb +33 -0
  93. data/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +10 -0
  94. data/generators/vulcanize/templates/monit/config/rubber/rubber-monit.yml +6 -0
  95. data/generators/vulcanize/templates/monit/templates.yml +1 -0
  96. data/generators/vulcanize/templates/munin/config/rubber/common/monit-munin.conf +8 -0
  97. data/generators/vulcanize/templates/munin/config/rubber/common/munin-node.conf +48 -0
  98. data/generators/vulcanize/templates/munin/config/rubber/common/munin-plugins.conf +11 -0
  99. data/generators/vulcanize/templates/munin/config/rubber/deploy-munin.rb +46 -0
  100. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-nginx.conf +8 -0
  101. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-plugins.conf +31 -0
  102. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +115 -0
  103. data/generators/vulcanize/templates/munin/config/rubber/rubber-munin.yml +8 -0
  104. data/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +55 -0
  105. data/generators/vulcanize/templates/munin/script/munin/example_simple.rb +24 -0
  106. data/generators/vulcanize/templates/munin/templates.yml +1 -0
  107. data/generators/vulcanize/templates/mysql/config/rubber/common/database.yml +12 -0
  108. data/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +169 -0
  109. data/generators/vulcanize/templates/mysql/config/rubber/role/db/apparmor-mysql.conf +46 -0
  110. data/generators/vulcanize/templates/mysql/config/rubber/role/db/crontab +14 -0
  111. data/generators/vulcanize/templates/mysql/config/rubber/role/db/monit-mysql.cnf +10 -0
  112. data/generators/vulcanize/templates/mysql/config/rubber/role/db/my.cnf +163 -0
  113. data/generators/vulcanize/templates/mysql/config/rubber/role/mysql_slave/mysql_slave_munin_plugin +51 -0
  114. data/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +47 -0
  115. data/generators/vulcanize/templates/mysql/templates.yml +1 -0
  116. data/generators/vulcanize/templates/mysql_cluster/config/rubber/common/mysql_cluster_migrations.rb +13 -0
  117. data/generators/vulcanize/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb +177 -0
  118. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_data/my.cnf +15 -0
  119. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_mgm/ndb_mgmd.cnf +39 -0
  120. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf +10 -0
  121. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/my.cnf +23 -0
  122. data/generators/vulcanize/templates/mysql_cluster/config/rubber/rubber-mysql_cluster.yml +32 -0
  123. data/generators/vulcanize/templates/mysql_cluster/templates.yml +1 -0
  124. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/database.yml +16 -0
  125. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf +10 -0
  126. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +153 -0
  127. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.conf +10 -0
  128. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.lua +5 -0
  129. data/generators/vulcanize/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb +52 -0
  130. data/generators/vulcanize/templates/mysql_proxy/config/rubber/rubber-mysql_proxy.yml +11 -0
  131. data/generators/vulcanize/templates/mysql_proxy/templates.yml +1 -0
  132. data/generators/vulcanize/templates/nginx/config/rubber/deploy-nginx.rb +45 -0
  133. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/crontab +9 -0
  134. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/monit-nginx.conf +8 -0
  135. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/nginx.conf +42 -0
  136. data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
  137. data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-index.html +30 -0
  138. data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
  139. data/generators/vulcanize/templates/nginx/config/rubber/rubber-nginx.yml +10 -0
  140. data/generators/vulcanize/templates/nginx/templates.yml +1 -0
  141. data/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +46 -0
  142. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +34 -0
  143. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +7 -0
  144. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +47 -0
  145. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf +46 -0
  146. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +35 -0
  147. data/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +15 -0
  148. data/generators/vulcanize/templates/passenger/templates.yml +3 -0
  149. data/generators/vulcanize/templates/postgresql/config/rubber/common/database.yml +12 -0
  150. data/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +131 -0
  151. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/crontab +14 -0
  152. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/monit-postgresql.conf +10 -0
  153. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/pg_hba.conf +89 -0
  154. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql-sysctl.conf +6 -0
  155. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +504 -0
  156. data/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +45 -0
  157. data/generators/vulcanize/templates/postgresql/templates.yml +1 -0
  158. data/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +37 -0
  159. data/generators/vulcanize/templates/redis/config/rubber/role/redis/crontab +8 -0
  160. data/generators/vulcanize/templates/redis/config/rubber/role/redis/monit-redis.conf +9 -0
  161. data/generators/vulcanize/templates/redis/config/rubber/role/redis/redis.conf +141 -0
  162. data/generators/vulcanize/templates/redis/config/rubber/rubber-redis.yml +4 -0
  163. data/generators/vulcanize/templates/redis/templates.yml +1 -0
  164. data/generators/vulcanize/templates/resque/config/initializers/resque.rb +15 -0
  165. data/generators/vulcanize/templates/resque/config/rubber/common/resque.yml +5 -0
  166. data/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +58 -0
  167. data/generators/vulcanize/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf +14 -0
  168. data/generators/vulcanize/templates/resque/config/rubber/role/resque_worker/monit-resque_worker.conf +19 -0
  169. data/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +18 -0
  170. data/generators/vulcanize/templates/resque/script/resque_worker_management.rb +144 -0
  171. data/generators/vulcanize/templates/resque/templates.rb +1 -0
  172. data/generators/vulcanize/templates/resque/templates.yml +3 -0
  173. data/generators/vulcanize/templates/sphinx/config/rubber/common/sphinx.yml +46 -0
  174. data/generators/vulcanize/templates/sphinx/config/rubber/deploy-sphinx.rb +112 -0
  175. data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/crontab +11 -0
  176. data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf +13 -0
  177. data/generators/vulcanize/templates/sphinx/config/rubber/rubber-sphinx.yml +6 -0
  178. data/generators/vulcanize/templates/sphinx/templates.yml +1 -0
  179. data/generators/vulcanize/vulcanize_generator.rb +184 -0
  180. data/lib/capistrano/hostcmd.rb +12 -0
  181. data/lib/generators/vulcanize/USAGE +6 -0
  182. data/lib/generators/vulcanize/templates/apache/config/rubber/deploy-apache.rb +51 -0
  183. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/deflate.conf +10 -0
  184. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/expires.conf +9 -0
  185. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/headers.conf +6 -0
  186. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/monit-apache.conf +8 -0
  187. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/ports.conf +8 -0
  188. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/setenvif.conf +52 -0
  189. data/lib/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache-vhost.conf +79 -0
  190. data/lib/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache.auth +7 -0
  191. data/lib/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-index.html +34 -0
  192. data/lib/generators/vulcanize/templates/apache/config/rubber/rubber-apache.yml +6 -0
  193. data/lib/generators/vulcanize/templates/apache/templates.yml +1 -0
  194. data/lib/generators/vulcanize/templates/base/Capfile +14 -0
  195. data/lib/generators/vulcanize/templates/base/Rakefile +23 -0
  196. data/lib/generators/vulcanize/templates/base/config/deploy.rb +56 -0
  197. data/lib/generators/vulcanize/templates/base/config/rubber/common/crontab +22 -0
  198. data/lib/generators/vulcanize/templates/base/config/rubber/common/monit-postfix.conf +8 -0
  199. data/lib/generators/vulcanize/templates/base/config/rubber/common/rubber.profile +13 -0
  200. data/lib/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +92 -0
  201. data/lib/generators/vulcanize/templates/base/config/rubber/deploy-util.rb +97 -0
  202. data/lib/generators/vulcanize/templates/base/config/rubber/rubber-dns.yml +78 -0
  203. data/lib/generators/vulcanize/templates/base/config/rubber/rubber-rvm.yml +33 -0
  204. data/lib/generators/vulcanize/templates/base/config/rubber/rubber.yml +233 -0
  205. data/lib/generators/vulcanize/templates/base/lib/tasks/rubber.rake +15 -0
  206. data/lib/generators/vulcanize/templates/base/script/cron-rake +18 -0
  207. data/lib/generators/vulcanize/templates/base/script/cron-runner +18 -0
  208. data/lib/generators/vulcanize/templates/base/script/cron-sh +67 -0
  209. data/lib/generators/vulcanize/templates/base/templates.rb +11 -0
  210. data/lib/generators/vulcanize/templates/base/templates.yml +6 -0
  211. data/lib/generators/vulcanize/templates/cassandra/config/rubber/deploy-cassandra.rb +88 -0
  212. data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.in.sh +60 -0
  213. data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.yaml +210 -0
  214. data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/log4j-server.properties +45 -0
  215. data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/monit-cassandra.conf +8 -0
  216. data/lib/generators/vulcanize/templates/cassandra/config/rubber/rubber-cassandra.yml +18 -0
  217. data/lib/generators/vulcanize/templates/cassandra/templates.yml +1 -0
  218. data/lib/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/haproxy/haproxy-mongrel.conf +23 -0
  219. data/lib/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/nginx/nginx-mongrel.conf +113 -0
  220. data/lib/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/rubber-complete.yml +41 -0
  221. data/lib/generators/vulcanize/templates/complete_mongrel_mysql/templates.yml +6 -0
  222. data/lib/generators/vulcanize/templates/complete_passenger/config/rubber/role/haproxy/haproxy-passenger.conf +21 -0
  223. data/lib/generators/vulcanize/templates/complete_passenger/config/rubber/rubber-complete.yml +40 -0
  224. data/lib/generators/vulcanize/templates/complete_passenger/templates.rb +9 -0
  225. data/lib/generators/vulcanize/templates/complete_passenger/templates.yml +9 -0
  226. data/lib/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +4 -0
  227. data/lib/generators/vulcanize/templates/complete_passenger_postgresql/templates.yml +4 -0
  228. data/lib/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +72 -0
  229. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/cruise +40 -0
  230. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/my.cnf +165 -0
  231. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/production.rb +8 -0
  232. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/site_config.rb +76 -0
  233. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/web_tools/cruise-nginx.conf +11 -0
  234. data/lib/generators/vulcanize/templates/cruise/config/rubber/rubber-cruise.yml +18 -0
  235. data/lib/generators/vulcanize/templates/cruise/templates.yml +1 -0
  236. data/lib/generators/vulcanize/templates/haproxy/config/rubber/deploy-haproxy.rb +45 -0
  237. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-base.conf +26 -0
  238. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-default.conf +8 -0
  239. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +9 -0
  240. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf +11 -0
  241. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslogd-default.conf +21 -0
  242. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/web_tools/haproxy-nginx.conf +10 -0
  243. data/lib/generators/vulcanize/templates/haproxy/config/rubber/rubber-haproxy.yml +7 -0
  244. data/lib/generators/vulcanize/templates/haproxy/templates.yml +1 -0
  245. data/lib/generators/vulcanize/templates/jetty/config/rubber/deploy-jetty.rb +59 -0
  246. data/lib/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.sh +589 -0
  247. data/lib/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.xml +199 -0
  248. data/lib/generators/vulcanize/templates/jetty/config/rubber/role/jetty/monit-jetty.conf +9 -0
  249. data/lib/generators/vulcanize/templates/jetty/config/rubber/rubber-jetty.yml +10 -0
  250. data/lib/generators/vulcanize/templates/jetty/templates.yml +1 -0
  251. data/lib/generators/vulcanize/templates/memcached/config/memcached.yml +28 -0
  252. data/lib/generators/vulcanize/templates/memcached/config/rubber/common/memcached.yml +14 -0
  253. data/lib/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached.conf +52 -0
  254. data/lib/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached_munin_plugin +249 -0
  255. data/lib/generators/vulcanize/templates/memcached/config/rubber/rubber-memcached.yml +7 -0
  256. data/lib/generators/vulcanize/templates/memcached/templates.yml +1 -0
  257. data/lib/generators/vulcanize/templates/minimal_mysql/templates.yml +7 -0
  258. data/lib/generators/vulcanize/templates/minimal_nodb/templates.yml +6 -0
  259. data/lib/generators/vulcanize/templates/mongrel/config/rubber/deploy-mongrel.rb +75 -0
  260. data/lib/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/mongrel_cluster.yml +12 -0
  261. data/lib/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/monit-mongrel.conf +20 -0
  262. data/lib/generators/vulcanize/templates/mongrel/config/rubber/rubber-mongrel.yml +9 -0
  263. data/lib/generators/vulcanize/templates/mongrel/templates.yml +1 -0
  264. data/lib/generators/vulcanize/templates/monit/config/rubber/common/monit-default.conf +15 -0
  265. data/lib/generators/vulcanize/templates/monit/config/rubber/common/monit.conf +252 -0
  266. data/lib/generators/vulcanize/templates/monit/config/rubber/deploy-monit.rb +33 -0
  267. data/lib/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +10 -0
  268. data/lib/generators/vulcanize/templates/monit/config/rubber/rubber-monit.yml +6 -0
  269. data/lib/generators/vulcanize/templates/monit/templates.yml +1 -0
  270. data/lib/generators/vulcanize/templates/munin/config/rubber/common/monit-munin.conf +8 -0
  271. data/lib/generators/vulcanize/templates/munin/config/rubber/common/munin-node.conf +48 -0
  272. data/lib/generators/vulcanize/templates/munin/config/rubber/common/munin-plugins.conf +11 -0
  273. data/lib/generators/vulcanize/templates/munin/config/rubber/deploy-munin.rb +46 -0
  274. data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-nginx.conf +8 -0
  275. data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-plugins.conf +31 -0
  276. data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +115 -0
  277. data/lib/generators/vulcanize/templates/munin/config/rubber/rubber-munin.yml +8 -0
  278. data/lib/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +55 -0
  279. data/lib/generators/vulcanize/templates/munin/script/munin/example_simple.rb +24 -0
  280. data/lib/generators/vulcanize/templates/munin/templates.yml +1 -0
  281. data/lib/generators/vulcanize/templates/mysql/config/rubber/common/database.yml +12 -0
  282. data/lib/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +169 -0
  283. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/apparmor-mysql.conf +46 -0
  284. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/crontab +14 -0
  285. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/monit-mysql.cnf +10 -0
  286. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/my.cnf +163 -0
  287. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/mysql_slave/mysql_slave_munin_plugin +51 -0
  288. data/lib/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +47 -0
  289. data/lib/generators/vulcanize/templates/mysql/templates.yml +1 -0
  290. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/common/mysql_cluster_migrations.rb +13 -0
  291. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb +177 -0
  292. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_data/my.cnf +15 -0
  293. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_mgm/ndb_mgmd.cnf +39 -0
  294. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf +10 -0
  295. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/my.cnf +23 -0
  296. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/rubber-mysql_cluster.yml +32 -0
  297. data/lib/generators/vulcanize/templates/mysql_cluster/templates.yml +1 -0
  298. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/database.yml +16 -0
  299. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf +10 -0
  300. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +153 -0
  301. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.conf +10 -0
  302. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.lua +5 -0
  303. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb +52 -0
  304. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/rubber-mysql_proxy.yml +11 -0
  305. data/lib/generators/vulcanize/templates/mysql_proxy/templates.yml +1 -0
  306. data/lib/generators/vulcanize/templates/nginx/config/rubber/deploy-nginx.rb +45 -0
  307. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/nginx/crontab +9 -0
  308. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/nginx/monit-nginx.conf +8 -0
  309. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/nginx/nginx.conf +42 -0
  310. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
  311. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-index.html +30 -0
  312. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
  313. data/lib/generators/vulcanize/templates/nginx/config/rubber/rubber-nginx.yml +10 -0
  314. data/lib/generators/vulcanize/templates/nginx/templates.yml +1 -0
  315. data/lib/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +46 -0
  316. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +34 -0
  317. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +7 -0
  318. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +47 -0
  319. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf +46 -0
  320. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +35 -0
  321. data/lib/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +15 -0
  322. data/lib/generators/vulcanize/templates/passenger/templates.yml +3 -0
  323. data/lib/generators/vulcanize/templates/postgresql/config/rubber/common/database.yml +12 -0
  324. data/lib/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +131 -0
  325. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/crontab +14 -0
  326. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/monit-postgresql.conf +10 -0
  327. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/pg_hba.conf +89 -0
  328. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql-sysctl.conf +6 -0
  329. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +504 -0
  330. data/lib/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +45 -0
  331. data/lib/generators/vulcanize/templates/postgresql/templates.yml +1 -0
  332. data/lib/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +37 -0
  333. data/lib/generators/vulcanize/templates/redis/config/rubber/role/redis/crontab +8 -0
  334. data/lib/generators/vulcanize/templates/redis/config/rubber/role/redis/monit-redis.conf +9 -0
  335. data/lib/generators/vulcanize/templates/redis/config/rubber/role/redis/redis.conf +141 -0
  336. data/lib/generators/vulcanize/templates/redis/config/rubber/rubber-redis.yml +4 -0
  337. data/lib/generators/vulcanize/templates/redis/templates.yml +1 -0
  338. data/lib/generators/vulcanize/templates/resque/config/initializers/resque.rb +15 -0
  339. data/lib/generators/vulcanize/templates/resque/config/rubber/common/resque.yml +5 -0
  340. data/lib/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +58 -0
  341. data/lib/generators/vulcanize/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf +14 -0
  342. data/lib/generators/vulcanize/templates/resque/config/rubber/role/resque_worker/monit-resque_worker.conf +19 -0
  343. data/lib/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +18 -0
  344. data/lib/generators/vulcanize/templates/resque/script/resque_worker_management.rb +144 -0
  345. data/lib/generators/vulcanize/templates/resque/templates.rb +1 -0
  346. data/lib/generators/vulcanize/templates/resque/templates.yml +3 -0
  347. data/lib/generators/vulcanize/templates/sphinx/config/rubber/common/sphinx.yml +46 -0
  348. data/lib/generators/vulcanize/templates/sphinx/config/rubber/deploy-sphinx.rb +112 -0
  349. data/lib/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/crontab +11 -0
  350. data/lib/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf +13 -0
  351. data/lib/generators/vulcanize/templates/sphinx/config/rubber/rubber-sphinx.yml +6 -0
  352. data/lib/generators/vulcanize/templates/sphinx/templates.yml +1 -0
  353. data/lib/generators/vulcanize/vulcanize_generator.rb +184 -0
  354. data/lib/rubber.rb +76 -0
  355. data/lib/rubber/capistrano.rb +1 -0
  356. data/lib/rubber/cloud.rb +13 -0
  357. data/lib/rubber/cloud/aws.rb +355 -0
  358. data/lib/rubber/cloud/base.rb +16 -0
  359. data/lib/rubber/configuration.rb +47 -0
  360. data/lib/rubber/dns.rb +13 -0
  361. data/lib/rubber/dns/base.rb +84 -0
  362. data/lib/rubber/dns/dyndns.rb +77 -0
  363. data/lib/rubber/dns/nettica.rb +117 -0
  364. data/lib/rubber/dns/zerigo.rb +115 -0
  365. data/lib/rubber/environment.rb +177 -0
  366. data/lib/rubber/generator.rb +209 -0
  367. data/lib/rubber/instance.rb +176 -0
  368. data/lib/rubber/railtie.rb +14 -0
  369. data/lib/rubber/recipes/rubber.rb +96 -0
  370. data/lib/rubber/recipes/rubber/bundles.rb +30 -0
  371. data/lib/rubber/recipes/rubber/deploy.rb +90 -0
  372. data/lib/rubber/recipes/rubber/instances.rb +445 -0
  373. data/lib/rubber/recipes/rubber/load_balancers.rb +44 -0
  374. data/lib/rubber/recipes/rubber/security_groups.rb +189 -0
  375. data/lib/rubber/recipes/rubber/setup.rb +534 -0
  376. data/lib/rubber/recipes/rubber/spot_requests.rb +23 -0
  377. data/lib/rubber/recipes/rubber/static_ips.rb +190 -0
  378. data/lib/rubber/recipes/rubber/utils.rb +226 -0
  379. data/lib/rubber/recipes/rubber/volumes.rb +264 -0
  380. data/lib/rubber/tasks/rubber.rb +279 -0
  381. data/lib/rubber/util.rb +72 -0
  382. data/rails/init.rb +6 -0
  383. data/test/environment_test.rb +144 -0
  384. data/test/generator_test.rb +370 -0
  385. data/test/instance_test.rb +96 -0
  386. data/test/test_helper.rb +14 -0
  387. data/test/util_test.rb +19 -0
  388. data/test/zerigo_test.rb +88 -0
  389. metadata +494 -0
@@ -0,0 +1,23 @@
1
+ namespace :rubber do
2
+
3
+ desc "Describes all your spot instance requests"
4
+ required_task :describe_spot_instance_requests do
5
+ requests = cloud.describe_spot_instance_requests()
6
+ requests.each do |request|
7
+ logger.info "======================"
8
+ logger.info "ID: #{request[:id]}"
9
+ logger.info "Created at: #{request[:created_at]}"
10
+ logger.info "Max. price: $#{request[:spot_price]}"
11
+ logger.info "State: #{request[:state]}"
12
+ logger.info "Instance type: #{request[:type]}"
13
+ logger.info "AMI: #{request[:image_id]}"
14
+ end
15
+ end
16
+
17
+ desc "Cancel the spot instances request for the given id"
18
+ required_task :cancel_spot_instances_request do
19
+ request_id = get_env('SPOT_INSTANCE_REQUEST_ID', 'The id of the spot instances request to cancel', true)
20
+ cloud.destroy_spot_instance_request(request_id)
21
+ end
22
+
23
+ end
@@ -0,0 +1,190 @@
1
+ namespace :rubber do
2
+
3
+
4
+ desc <<-DESC
5
+ Sets up static IPs for the instances configured to have them
6
+ DESC
7
+ required_task :setup_static_ips do
8
+ rubber_instances.each do |ic|
9
+ env = rubber_cfg.environment.bind(ic.role_names, ic.name)
10
+ if env.use_static_ip
11
+ artifacts = rubber_instances.artifacts
12
+ ip = artifacts['static_ips'][ic.name] rescue nil
13
+
14
+ # first allocate the static ip if we don't have a global record (artifacts) for it
15
+ if ! ip
16
+ logger.info "Allocating static IP for #{ic.full_name}"
17
+ ip = allocate_static_ip()
18
+ artifacts['static_ips'][ic.name] = ip
19
+ rubber_instances.save
20
+ end
21
+
22
+ # then, associate it if we don't have a record (on instance) of association
23
+ if ! ic.static_ip
24
+ logger.info "Associating static ip #{ip} with #{ic.full_name}"
25
+ associate_static_ip(ip, ic.instance_id)
26
+
27
+ instance = cloud.describe_instances(ic.instance_id).first
28
+ ic.external_host = instance[:external_host]
29
+ ic.internal_host = instance[:internal_host]
30
+ ic.external_ip = ip
31
+ ic.static_ip = ip
32
+ rubber_instances.save()
33
+
34
+ logger.info "Waiting for static ip to associate"
35
+ while true do
36
+ task :_wait_for_static_ip, :hosts => ip do
37
+ run "echo"
38
+ end
39
+ begin
40
+ _wait_for_static_ip
41
+ rescue ConnectionError
42
+ sleep 2
43
+ logger.info "Failed to connect to static ip #{ip}, retrying"
44
+ retry
45
+ end
46
+ break
47
+ end
48
+ end
49
+
50
+ end
51
+ end
52
+ end
53
+
54
+ desc <<-DESC
55
+ Shows the configured static IPs
56
+ DESC
57
+ required_task :describe_static_ips do
58
+ results = []
59
+ format = "%-10s %-15s %-30s"
60
+ results << format % %w[InstanceID IP Alias]
61
+
62
+ ips = cloud.describe_static_ips()
63
+ ips.each do |ip_data|
64
+ instance_id = ip_data[:instance_id]
65
+ ip = ip_data[:ip]
66
+
67
+ local_alias = find_alias(ip, instance_id, false)
68
+
69
+ results << format % [instance_id || "Unassigned", ip, local_alias || "Unknown"]
70
+ end
71
+
72
+ results.each {|r| logger.info r}
73
+ end
74
+
75
+ desc <<-DESC
76
+ Deallocates the given static ip
77
+ DESC
78
+ required_task :destroy_static_ip do
79
+ ip = get_env('IP', "Static IP (run rubber:describe_static_ips for a list)", true)
80
+ destroy_static_ip(ip)
81
+ end
82
+
83
+ desc 'Move a static IP address from DONOR machine to RECEIVER machine.'
84
+ task :move_static_ip do
85
+ donor_alias = get_env 'DONOR', 'Instance alias to get the IP from (e.g., web01)', true
86
+ receiver_alias = get_env 'RECEIVER', 'Instance alias to assign the IP to (e.g., web02)', true
87
+
88
+ # Sanity checks
89
+ donor = rubber_instances[donor_alias]
90
+ fatal "Instance does not exist: #{donor_alias}" unless donor
91
+
92
+ static_ip = donor.static_ip
93
+ fatal 'No static IP address to move exists' unless static_ip && static_ip != ''
94
+
95
+ receiver = rubber_instances[receiver_alias]
96
+ fatal "Instance does not exist: #{receiver_alias}" unless receiver
97
+
98
+ # Temporary removal of the instances.
99
+ old_donor = rubber_instances.remove(donor_alias)
100
+ old_receiver = rubber_instances.remove(receiver_alias)
101
+
102
+ rubber_instances.save
103
+
104
+ # Getting rid of alias->IP mappings and SSH's known_hosts records.
105
+ load_roles
106
+ setup_aliases
107
+ cleanup_known_hosts(old_donor)
108
+ cleanup_known_hosts(old_receiver)
109
+
110
+ # Detachment of EIPA.
111
+ success = cloud.detach_static_ip(static_ip)
112
+ fatal "Failed to detach static IP address #{static_ip}" unless success
113
+ rubber_instances.artifacts['static_ips'].delete(old_donor.name)
114
+
115
+ rubber_instances.save
116
+
117
+ # Attachment of EIPA.
118
+ success = cloud.attach_static_ip(static_ip, old_receiver.instance_id)
119
+ fatal "Failed to associate static IP address #{static_ip}" unless success
120
+
121
+ print "Waiting for #{receiver_alias} to get the address"
122
+ while true do
123
+ print '.'
124
+ sleep 3
125
+ instance = cloud.describe_instances(old_receiver.instance_id).first
126
+ break if instance[:external_ip] == static_ip
127
+ end
128
+
129
+ # Partial cleanup of static IP records.
130
+ rubber_instances.artifacts['static_ips'][old_receiver.name] = static_ip
131
+
132
+ rubber_instances.save
133
+
134
+ # First half of the sync.
135
+ new_receiver = Rubber::Configuration::InstanceItem.new(old_receiver.name,
136
+ old_receiver.domain, old_receiver.roles, old_receiver.instance_id,
137
+ old_receiver.security_groups)
138
+ new_receiver.static_ip = static_ip
139
+ rubber_instances.add(new_receiver)
140
+
141
+ rubber_instances.save
142
+
143
+ refresh_instance(receiver_alias)
144
+
145
+ print "Waiting for #{donor_alias} to get a new address"
146
+ while true do
147
+ print '.'
148
+ sleep 3
149
+ instance = cloud.describe_instances(old_donor.instance_id).first
150
+ break if instance[:external_ip] && instance[:external_ip] != ''
151
+ end
152
+
153
+ # Second half of the sync.
154
+ new_donor = Rubber::Configuration::InstanceItem.new(old_donor.name,
155
+ old_donor.domain, old_donor.roles, old_donor.instance_id,
156
+ old_donor.security_groups)
157
+ rubber_instances.add(new_donor)
158
+
159
+ rubber_instances.save
160
+
161
+ refresh_instance(donor_alias)
162
+
163
+ logger.info "Run 'cap rubber:describe_static_ips' to check the allocated ones"
164
+ end
165
+
166
+ def allocate_static_ip()
167
+ ip = cloud.create_static_ip()
168
+ fatal "Failed to allocate static ip" if ip.nil?
169
+ return ip
170
+ end
171
+
172
+ def associate_static_ip(ip, instance_id)
173
+ success = cloud.attach_static_ip(ip, instance_id)
174
+ fatal "Failed to associate static ip" unless success
175
+ end
176
+
177
+ def destroy_static_ip(ip)
178
+ logger.info "Releasing static ip: #{ip}"
179
+ cloud.destroy_static_ip(ip) rescue logger.info("IP was not attached")
180
+
181
+ logger.info "Removing ip #{ip} from rubber instances file"
182
+ artifacts = rubber_instances.artifacts
183
+ artifacts['static_ips'].delete_if {|k,v| v == ip}
184
+ rubber_instances.each do |ic|
185
+ ic.static_ip = nil if ic.static_ip == ip
186
+ end
187
+ rubber_instances.save
188
+ end
189
+
190
+ end
@@ -0,0 +1,226 @@
1
+ namespace :rubber do
2
+
3
+ desc <<-DESC
4
+ Convenience task for creating a staging instance for the given RUBBER_ENV/RAILS_ENV.
5
+ By default this task assigns all known roles when creating the instance,
6
+ but you can specify a different default in rubber.yml:staging_roles
7
+ At the end, the instance will be up and running
8
+ e.g. RUBBER_ENV=matt cap create_staging
9
+ DESC
10
+ required_task :create_staging do
11
+ if rubber_instances.size > 0
12
+ value = Capistrano::CLI.ui.ask("The #{RUBBER_ENV} environment already has instances, Are you SURE you want to create a staging instance that may interact with them [y/N]?: ")
13
+ fatal("Exiting", 0) if value !~ /^y/
14
+ end
15
+ instance_alias = ENV['ALIAS'] = rubber.get_env("ALIAS", "Hostname to use for staging instance", true, RUBBER_ENV)
16
+ default_roles = rubber_env.staging_roles || "*"
17
+ roles = ENV['ROLES'] = rubber.get_env("ROLES", "Roles to use for staging instance", true, default_roles)
18
+
19
+ if rubber_instances[instance_alias]
20
+ logger.info "Instance already exists, skipping to bootstrap"
21
+ else
22
+ rubber.create
23
+ end
24
+
25
+ # stop everything before so monit doesn't start stuff during bootstrapping
26
+ # if its already installed due to a bundled instance
27
+ deploy.stop rescue nil
28
+
29
+ rubber.bootstrap
30
+
31
+ # stop everything after in case package upgrades during bootstrap start up
32
+ # services - we should be able to safely do a deploy:start below
33
+ deploy.stop rescue nil
34
+
35
+ # some bootstraps update code (bootstrap_db) but if you don't have that role, need to do it here
36
+ # Since release directory variable gets reused by cap, we have to just do the symlink here - doing
37
+ # a update again will fail
38
+ if ! fetch(:rubber_code_was_updated, false)
39
+ deploy.update_code
40
+ end
41
+ deploy.symlink
42
+ deploy.migrate
43
+ deploy.start
44
+ end
45
+
46
+ desc <<-DESC
47
+ Destroy the staging instance for the given RUBBER_ENV.
48
+ DESC
49
+ task :destroy_staging do
50
+ ENV['ALIAS'] = rubber.get_env("ALIAS", "Hostname of staging instance to be destroyed", true, RUBBER_ENV)
51
+ rubber.destroy
52
+ end
53
+
54
+ desc <<-DESC
55
+ Live tail of rails log files for all machines
56
+ By default tails the rails logs for the current RUBBER_ENV, but one can
57
+ set FILE=/path/file.*.glob to tails a different set
58
+ DESC
59
+ task :tail_logs, :roles => :app do
60
+ log_file_glob = rubber.get_env("FILE", "Log files to tail", true, "#{current_path}/log/#{RUBBER_ENV}*.log")
61
+ run "tail -qf #{log_file_glob}" do |channel, stream, data|
62
+ puts # for an extra line break before the host name
63
+ puts data
64
+ break if stream == :err
65
+ end
66
+ end
67
+
68
+ # Use instead of task to define a capistrano task that runs serially instead of in parallel
69
+ # The :groups option specifies how many groups to partition the servers into so that we can
70
+ # do the task for N (= total/groups) servers at a time. When multiple roles are supplied,
71
+ # this tries to be intelligent and slice up each role independently, but runs the slices together
72
+ # so that things don't take too long, e.g. adding an :api role to some :app servers, when restarting
73
+ # you don't want to do the api first, then the others as this would take a long time, so instead
74
+ # it does some :api and some :app, then some more of each
75
+ #
76
+ def serial_task(ns, name, options = {}, &block)
77
+ # first figure out server names for the passed in roles - when no roles
78
+ # are passed in, use all servers
79
+ serial_roles = Array(options[:roles])
80
+ servers = {}
81
+ if serial_roles.empty?
82
+ all_servers = []
83
+ self.roles.each do |rolename, serverdefs|
84
+ all_servers += serverdefs.collect {|server| server.host}
85
+ end
86
+ servers[:_serial_all] = all_servers.uniq.sort
87
+ else
88
+ # get servers for each role
89
+ self.roles.each do |rolename, serverdefs|
90
+ if serial_roles.include?(rolename)
91
+ servers[rolename] ||= []
92
+ servers[rolename] += serverdefs.collect {|server| server.host}
93
+ end
94
+ end
95
+
96
+ # Remove duplication of servers - roles which come first in list
97
+ # have precedence, so the servers show up in that group
98
+ serial_roles.each_with_index do |rolename, i|
99
+ servers[rolename] ||= []
100
+ serial_roles[i+1..-1].each do |r|
101
+ servers[r] -= servers[rolename]
102
+ end
103
+ servers[rolename] = servers[rolename].uniq.sort
104
+ end
105
+ end
106
+
107
+ # group each role's servers into slices, but combine slices across roles
108
+ slices = []
109
+ servers.each do |rolename, svrs|
110
+ next if svrs.size == 0
111
+ # figure out size of each slice by dividing server count by # of groups
112
+ slice_size = (Float(svrs.size) / (options.delete(:groups) || 2)).round
113
+ slice_size = 1 if slice_size == 0
114
+ slice_idx = 0
115
+ svrs.each_slice(slice_size) do |srv_slice|
116
+ slices[slice_idx] ||= []
117
+ slices[slice_idx] += srv_slice
118
+ slice_idx += 1
119
+ end
120
+ end
121
+ # for each slice, define a new task specific to the hosts in that slice
122
+ task_syms = []
123
+ slices.each do |server_group|
124
+ servers = server_group.map{|s| s.gsub(/\..*/, '')}.join("_")
125
+ task_sym = "_serial_task_#{name.to_s}_#{servers}".to_sym
126
+ task_syms << task_sym
127
+ ns.task task_sym, options.merge(:hosts => server_group), &block
128
+ end
129
+
130
+ # create the top level task that calls all the serial ones
131
+ ns.task name, options do
132
+ task_syms.each do |t|
133
+ ns.send t
134
+ end
135
+ end
136
+ end
137
+
138
+ def find_alias(ip, instance_id, do_connect=true)
139
+ if instance_id
140
+ instance = rubber_instances.find {|i| i.instance_id == instance_id }
141
+ local_alias = instance.full_name if instance
142
+ end
143
+ local_alias ||= File.read("/etc/hosts").grep(/#{ip}/).first.split[1] rescue nil
144
+ if ! local_alias && do_connect
145
+ task :_get_ip, :hosts => ip do
146
+ local_alias = "* " + capture("hostname").strip
147
+ end
148
+ _get_ip rescue ConnectionError
149
+ end
150
+ return local_alias
151
+ end
152
+
153
+ def prepare_script(name, contents, stop_on_error_cmd=rubber_env.stop_on_error_cmd)
154
+ script = "/tmp/#{name}"
155
+ # this lets us abort a script if a command in the middle of it errors out
156
+ contents = "#{stop_on_error_cmd}\n#{contents}" if stop_on_error_cmd
157
+ put(contents, script)
158
+ return script
159
+ end
160
+
161
+ def run_script(name, contents, opts = {})
162
+ args = opts.delete(:script_args)
163
+ script = prepare_script(name, contents)
164
+ run "bash #{script} #{args}", opts
165
+ end
166
+
167
+ def sudo_script(name, contents, opts = {})
168
+ args = opts.delete(:script_args)
169
+ script = prepare_script(name, contents)
170
+ run "#{sudo} bash -l #{script} #{args}", opts
171
+ end
172
+
173
+ def top.rsudo(command, opts = {}, &block)
174
+ user = opts.delete(:as)
175
+ args = "-H -u #{user}" if user
176
+ run "#{sudo opts} #{args} bash -l -c '#{command}'", opts, &block
177
+ end
178
+
179
+ def get_env(name, desc, required=false, default=nil)
180
+ value = ENV.delete(name)
181
+ msg = "#{desc}"
182
+ msg << " [#{default}]" if default
183
+ msg << ": "
184
+ value = Capistrano::CLI.ui.ask(msg) unless value
185
+ value = value.size == 0 ? default : value
186
+ fatal "#{name} is required, pass using environment or enter at prompt" if required && ! value
187
+ return value
188
+ end
189
+
190
+ def fatal(msg, code=1)
191
+ logger.info msg
192
+ exit code
193
+ end
194
+
195
+ # Returns a map of "hostvar_<hostname>" => value for the given config value for each instance host
196
+ # This is used to run capistrano tasks scoped to the correct role/host so that a config value
197
+ # specific to a role/host will only be used for that role/host, e.g. the list of packages to
198
+ # be installed.
199
+ def get_host_options(cfg_name, &block)
200
+ opts = {}
201
+ rubber_instances.each do | ic|
202
+ env = rubber_cfg.environment.bind(ic.role_names, ic.name)
203
+ cfg_value = env[cfg_name]
204
+ if cfg_value
205
+ if block
206
+ cfg_value = block.call(cfg_value)
207
+ end
208
+ opts["hostvar_#{ic.full_name}"] = cfg_value if cfg_value && cfg_value.strip.size > 0
209
+ end
210
+ end
211
+ return opts
212
+ end
213
+
214
+ # some bootstraps update code (bootstrap_db), so keep track so we don't do it multiple times
215
+ after "deploy:update_code" do
216
+ set :rubber_code_was_updated, true
217
+ end
218
+
219
+ def update_code_for_bootstrap
220
+ unless (fetch(:rubber_code_was_updated, false))
221
+ deploy.setup
222
+ deploy.update_code
223
+ end
224
+ end
225
+
226
+ end
@@ -0,0 +1,264 @@
1
+ namespace :rubber do
2
+
3
+ desc <<-DESC
4
+ Sets up persistent volumes in the cloud
5
+ All volumes defined in rubber.yml will be created if neccessary, and attached/mounted on their associated instances
6
+ DESC
7
+ required_task :setup_volumes do
8
+ rubber_instances.filtered.each do |ic|
9
+ env = rubber_cfg.environment.bind(ic.role_names, ic.name)
10
+ created_vols = []
11
+ vol_specs = env.volumes || []
12
+ vol_specs.each do |vol_spec|
13
+ created_vols << setup_volume(ic, vol_spec)
14
+ end
15
+ created_vols.compact!
16
+
17
+ created_parts = []
18
+ partition_specs = env.local_volumes || []
19
+ partition_specs.each do |partition_spec|
20
+ created_parts << setup_partition(ic, partition_spec)
21
+ end
22
+ created_parts.compact!
23
+ zero_partitions(ic, created_parts)
24
+ created_vols += created_parts
25
+
26
+ created_vols = created_vols.compact.uniq
27
+ raid_specs = env.raid_volumes || []
28
+ raid_specs.each do |raid_spec|
29
+ # we want to format if we created the ec2 volumes, or if we don't have any
30
+ # ec2 volumes and are just creating raid array from ephemeral stores
31
+ format = raid_spec['source_devices'].all? {|dev| created_vols.include?(dev)}
32
+ setup_raid_volume(ic, raid_spec, format)
33
+ end
34
+ end
35
+ end
36
+
37
+ desc <<-DESC
38
+ Shows the configured persistent volumes
39
+ DESC
40
+ required_task :describe_volumes do
41
+ results = []
42
+ format = "%-20s %-15s %-15s %-20s"
43
+ results << format % %w[Id Status Attached Instance]
44
+
45
+ volumes = cloud.describe_volumes()
46
+ volumes.each do |volume|
47
+ results << format % [volume[:id], volume[:status], volume[:attachment_status], volume[:attachment_instance_id]]
48
+ end
49
+
50
+ results.each {|r| logger.info r}
51
+ end
52
+
53
+ desc <<-DESC
54
+ Shows the configured persistent volumes
55
+ DESC
56
+ required_task :destroy_volume do
57
+ volume_id = get_env('VOLUME_ID', "Volume ID", true)
58
+ destroy_volume(volume_id)
59
+ end
60
+
61
+ def create_volume(size, zone)
62
+ volumeId = cloud.create_volume(size.to_s, zone)
63
+ fatal "Failed to create volume" if volumeId.nil?
64
+ return volumeId
65
+ end
66
+
67
+ def attach_volume(vol_id, instance_id, device)
68
+ cloud.attach_volume(vol_id, instance_id, device)
69
+ end
70
+
71
+ def setup_volume(ic, vol_spec)
72
+ created = nil
73
+ key = "#{ic.name}_#{vol_spec['device']}"
74
+ artifacts = rubber_instances.artifacts
75
+ vol_id = artifacts['volumes'][key]
76
+
77
+ # first create the volume if we don't have a global record (artifacts) for it
78
+ if ! vol_id
79
+ logger.info "Creating volume for #{ic.full_name}:#{vol_spec['device']}"
80
+ vol_id = create_volume(vol_spec['size'], vol_spec['zone'])
81
+ artifacts['volumes'][key] = vol_id
82
+ rubber_instances.save
83
+ created = vol_spec['device']
84
+ end
85
+
86
+ # then, attach it if we don't have a record (on instance) of attachment
87
+ ic.volumes ||= []
88
+ if ! ic.volumes.include?(vol_id)
89
+ logger.info "Attaching volume #{vol_id} to #{ic.full_name}:#{vol_spec['device']}"
90
+ attach_volume(vol_id, ic.instance_id, vol_spec['device'])
91
+ ic.volumes << vol_id
92
+ rubber_instances.save
93
+
94
+ print "Waiting for volume to attach"
95
+ while true do
96
+ print "."
97
+ sleep 2
98
+ volume = cloud.describe_volumes(vol_id).first
99
+ break if volume[:status] == "in-use"
100
+ end
101
+ print "\n"
102
+
103
+ # we don't mount/format at this time if we are doing a RAID array
104
+ if vol_spec['mount'] && vol_spec['filesystem']
105
+ # then format/mount/etc if we don't have an entry in hosts file
106
+ task :_setup_volume, :hosts => ic.external_ip do
107
+ rubber.sudo_script 'setup_volume', <<-ENDSCRIPT
108
+ if ! grep -q '#{vol_spec['mount']}' /etc/fstab; then
109
+ if mount | grep -q '#{vol_spec['mount']}'; then
110
+ umount '#{vol_spec['mount']}'
111
+ fi
112
+ mv /etc/fstab /etc/fstab.bak
113
+ cat /etc/fstab.bak | grep -v '#{vol_spec['mount']}' > /etc/fstab
114
+ echo '#{vol_spec['device']} #{vol_spec['mount']} #{vol_spec['filesystem']} noatime 0 0 # rubber volume #{vol_id}' >> /etc/fstab
115
+
116
+ #{('yes | mkfs -t ' + vol_spec['filesystem'] + ' ' + vol_spec['device']) if created}
117
+ mkdir -p '#{vol_spec['mount']}'
118
+ mount '#{vol_spec['mount']}'
119
+ fi
120
+ ENDSCRIPT
121
+ end
122
+ _setup_volume
123
+ end
124
+
125
+ end
126
+ return created
127
+ end
128
+
129
+ def setup_partition(ic, partition_spec)
130
+ created = nil
131
+ part_id = partition_spec['partition_device']
132
+
133
+ # Only create the partition if we haven't already done so
134
+ ic.partitions ||= []
135
+ if ! ic.partitions.include?(part_id)
136
+ # then format/mount/etc if we don't have an entry in hosts file
137
+ task :_setup_partition, :hosts => ic.external_ip do
138
+ rubber.sudo_script 'setup_partition', <<-ENDSCRIPT
139
+ if ! fdisk -l 2>&1 | grep -q '#{partition_spec['partition_device']}'; then
140
+ if grep -q '#{partition_spec['disk_device']}\\b' /etc/fstab; then
141
+ umount #{partition_spec['disk_device']}
142
+ mv /etc/fstab /etc/fstab.bak
143
+ cat /etc/fstab.bak | grep -v '#{partition_spec['disk_device']}\\b' > /etc/fstab
144
+ fi
145
+
146
+ # partition format is: Start (blank is first available),Size(MB due to -uM),Id(83=linux,82=swap,etc),Bootable
147
+ echo "#{partition_spec['start']},#{partition_spec['size']},#{partition_spec['type']},#{partition_spec['bootable']}" | sfdisk -L -uM #{partition_spec['disk_device']}
148
+ fi
149
+ ENDSCRIPT
150
+ end
151
+ _setup_partition
152
+
153
+ ic.partitions << part_id
154
+ rubber_instances.save
155
+ created = part_id
156
+
157
+ end
158
+
159
+ return created
160
+ end
161
+
162
+ def zero_partitions(ic, partitions)
163
+ env = rubber_cfg.environment.bind(ic.role_names, ic.name)
164
+
165
+ # don't zero out the ones that we weren't told to
166
+ partitions.delete_if do |part|
167
+ spec = env.local_volumes.find {|s| s['partition_device'] == part}
168
+ ! spec['zero']
169
+ end
170
+
171
+ if partitions.size > 0
172
+ zero_script = ""
173
+ partitions.each do |partition|
174
+ zero_script << "nohup dd if=/dev/zero bs=1M of=#{partition} &> /dev/null &\n"
175
+ end
176
+ # then format/mount/etc if we don't have an entry in hosts file
177
+ task :_zero_partitions, :hosts => ic.external_ip do
178
+ rubber.sudo_script 'zero_partitions', <<-ENDSCRIPT
179
+ # zero out parition for performance (see amazon DevGuide)
180
+ echo "Zeroing out raid partitions to improve performance, this way take a while"
181
+ #{zero_script}
182
+
183
+ echo "Waiting for partitions to zero out"
184
+ while true; do
185
+ if ! ps ax | grep -q "[d]d.*/dev/zero"; then exit; fi
186
+ echo -n .
187
+ sleep 1
188
+ done
189
+ ENDSCRIPT
190
+ end
191
+ _zero_partitions
192
+ end
193
+ end
194
+
195
+ def setup_raid_volume(ic, raid_spec, create=false)
196
+ if create
197
+ mdadm_init = "mdadm --create #{raid_spec['device']} --level #{raid_spec['raid_level']} --raid-devices #{raid_spec['source_devices'].size} #{raid_spec['source_devices'].sort.join(' ')}"
198
+ else
199
+ mdadm_init = "mdadm --assemble #{raid_spec['device']} #{raid_spec['source_devices'].sort.join(' ')}"
200
+ end
201
+
202
+ task :_setup_raid_volume, :hosts => ic.external_ip do
203
+ rubber.sudo_script 'setup_raid_volume', <<-ENDSCRIPT
204
+ if ! grep -q '#{raid_spec['device']}' /etc/fstab; then
205
+ if mount | grep -q '#{raid_spec['mount']}'; then
206
+ umount '#{raid_spec['mount']}'
207
+ fi
208
+ mv /etc/fstab /etc/fstab.bak
209
+ cat /etc/fstab.bak | grep -v '#{raid_spec['mount']}' > /etc/fstab
210
+ echo '#{raid_spec['device']} #{raid_spec['mount']} #{raid_spec['filesystem']} noatime 0 0 # rubber raid volume' >> /etc/fstab
211
+
212
+ # seems to help devices initialize, otherwise mdadm fails because
213
+ # device not ready even though ec2 says the volume is attached
214
+ fdisk -l &> /dev/null
215
+
216
+ #{mdadm_init}
217
+
218
+ # set reconstruction speed
219
+ echo $((30*1024)) > /proc/sys/dev/raid/speed_limit_min
220
+
221
+ echo 'DEVICE /dev/hd*[0-9] /dev/sd*[0-9]' > /etc/mdadm/mdadm.conf
222
+ mdadm --detail --scan >> /etc/mdadm/mdadm.conf
223
+
224
+ mv /etc/rc.local /etc/rc.local.bak
225
+ echo "mdadm --assemble --scan" > /etc/rc.local
226
+ chmod +x /etc/rc.local
227
+
228
+ #{('yes | mkfs -t ' + raid_spec['filesystem'] + ' ' + raid_spec['device']) if create}
229
+ mkdir -p '#{raid_spec['mount']}'
230
+ mount '#{raid_spec['mount']}'
231
+ fi
232
+ ENDSCRIPT
233
+ end
234
+ _setup_raid_volume
235
+ end
236
+
237
+ def destroy_volume(volume_id)
238
+
239
+ logger.info "Detaching volume #{volume_id}"
240
+ cloud.detach_volume(volume_id) rescue logger.info("Volume was not attached")
241
+
242
+ print "Waiting for volume to detach"
243
+ while true do
244
+ print "."
245
+ sleep 2
246
+ volume = cloud.describe_volumes(volume_id).first
247
+ status = volume && volume[:attachment_status]
248
+ break if !status || status == "detached"
249
+ end
250
+ print "\n"
251
+
252
+ logger.info "Deleting volume #{volume_id}"
253
+ cloud.destroy_volume(volume_id)
254
+
255
+ logger.info "Removing volume #{volume_id} from rubber instances file"
256
+ artifacts = rubber_instances.artifacts
257
+ artifacts['volumes'].delete_if {|k,v| v == volume_id}
258
+ rubber_instances.each do |ic|
259
+ ic.volumes.delete(volume_id) if ic.volumes
260
+ end
261
+ rubber_instances.save
262
+ end
263
+
264
+ end