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,279 @@
1
+ require 'fileutils'
2
+ require 'date'
3
+ require 'time'
4
+ require 'aws/s3'
5
+ require 'rubber'
6
+
7
+ namespace :rubber do
8
+
9
+ def rubber_env()
10
+ Rubber::Configuration.rubber_env
11
+ end
12
+
13
+ def rubber_instances()
14
+ Rubber::Configuration.rubber_instances
15
+ end
16
+
17
+ def cloud_provider
18
+ rubber_env.cloud_providers[rubber_env.cloud_provider]
19
+ end
20
+
21
+ def init_s3()
22
+ AWS::S3::Base.establish_connection!(:access_key_id => cloud_provider.access_key, :secret_access_key => cloud_provider.secret_access_key)
23
+ end
24
+
25
+ desc "Generate system config files by transforming the files in the config tree"
26
+ task :config do
27
+ cfg = Rubber::Configuration.get_configuration(RUBBER_ENV)
28
+ instance_alias = cfg.environment.current_host
29
+ instance = cfg.instance[instance_alias]
30
+ if instance
31
+ roles = instance.role_names
32
+ env = cfg.environment.bind(roles, instance_alias)
33
+ gen = Rubber::Configuration::Generator.new("#{RUBBER_ROOT}/config/rubber", roles, instance_alias)
34
+ elsif RUBBER_ENV == 'development'
35
+ roles = cfg.environment.known_roles
36
+ role_items = roles.collect do |r|
37
+ Rubber::Configuration::RoleItem.new(r, r == "db" ? {'primary' => true} : {})
38
+ end
39
+ env = cfg.environment.bind(roles, instance_alias)
40
+ domain = env.domain
41
+ instance = Rubber::Configuration::InstanceItem.new(instance_alias, domain, role_items, 'dummyid', ['dummygroup'])
42
+ instance.external_host = instance.full_name
43
+ instance.external_ip = "127.0.0.1"
44
+ instance.internal_host = instance.full_name
45
+ instance.internal_ip = "127.0.0.1"
46
+ cfg.instance.add(instance)
47
+ gen = Rubber::Configuration::Generator.new("#{RUBBER_ROOT}/config/rubber", roles, instance_alias)
48
+ gen.fake_root ="#{RUBBER_ROOT}/tmp/rubber"
49
+ else
50
+ puts "Instance not found for host: #{instance_alias}"
51
+ exit 1
52
+ end
53
+
54
+ if ENV['NO_POST']
55
+ gen.no_post = true
56
+ end
57
+ if ENV['FILE']
58
+ gen.file_pattern = ENV['FILE']
59
+ end
60
+ if ENV['FORCE']
61
+ gen.force = true
62
+ end
63
+ gen.stop_on_error_cmd = env.stop_on_error_cmd
64
+ gen.run
65
+
66
+ end
67
+
68
+ desc <<-DESC
69
+ Rotate rails app server logfiles. Should be run right after midnight.
70
+ The following arguments affect behavior:
71
+ LOG_DIR (required): Directory where log files are located
72
+ LOG_FILE (*.log): File pattern to match to find logs to rotate
73
+ LOG_AGE (7): Delete rotated logs older than this many days in the past
74
+ DESC
75
+ task :rotate_logs do
76
+ log_src_dir = get_env('LOG_DIR', true)
77
+ log_file_glob = get_env('LOG_FILES') || "*.log"
78
+ log_file_age = (get_env('LOG_AGE') || 7).to_i
79
+
80
+ rotated_date = (Date.today - 1).strftime('%Y%m%d')
81
+ puts "Rotating logfiles located at: #{log_src_dir}/#{log_file_glob}"
82
+ Dir["#{log_src_dir}/#{log_file_glob}"].each do |logfile|
83
+ rotated_file = "#{logfile}.#{rotated_date}"
84
+ if File.exist?(rotated_file)
85
+ rotated_file += "_#{Time.now.to_i}"
86
+ end
87
+ FileUtils.cp(logfile, rotated_file)
88
+ File.truncate logfile, 0
89
+ end
90
+
91
+ tdate = Date.today - log_file_age
92
+ threshold = Time.local(tdate.year, tdate.month, tdate.day)
93
+ puts "Cleaning rotated log files older than #{log_file_age} days"
94
+ Dir["#{log_src_dir}/#{log_file_glob}.[0-9]*"].each do |logfile|
95
+ if File.mtime(logfile) < threshold
96
+ FileUtils.rm_f(logfile)
97
+ end
98
+ end
99
+ end
100
+
101
+
102
+ desc <<-DESC
103
+ Backup database to given backup directory
104
+ The following arguments affect behavior:
105
+ BACKUP_DIR (required): Directory where backups will be stored
106
+ BACKUP_NAME (required): What to name the backup
107
+ BACKUP_CMD (required): Command used to backup
108
+ BACKUP_AGE (3): Delete rotated logs older than this many days in the past
109
+ DESC
110
+ task :backup do
111
+ dir = get_env('BACKUP_DIR', true)
112
+ name = get_env('BACKUP_NAME', true)
113
+ cmd = get_env('BACKUP_CMD', true)
114
+ age = (get_env('BACKUP_AGE') || 3).to_i
115
+
116
+ time_stamp = Time.now.strftime("%Y-%m-%d_%H-%M")
117
+ FileUtils.mkdir_p(dir)
118
+
119
+ backup_cmd = cmd.gsub(/%([^%]+)%/, '#{\1}')
120
+ backup_cmd = eval('%Q{' + backup_cmd + '}')
121
+
122
+ puts "Backing up with command:"
123
+ sh backup_cmd
124
+ puts "Backup created"
125
+
126
+ s3_prefix = "#{name}/"
127
+ backup_bucket = cloud_provider.backup_bucket
128
+ if backup_bucket
129
+ init_s3
130
+ unless AWS::S3::Bucket.list.find { |b| b.name == backup_bucket }
131
+ AWS::S3::Bucket.create(backup_bucket)
132
+ end
133
+ newest = Dir.entries(dir).grep(/^[^.]/).sort_by {|f| File.mtime(File.join(dir,f))}.last
134
+ dest = "#{s3_prefix}#{newest}"
135
+ puts "Saving backup to S3: #{backup_bucket}:#{dest}"
136
+ AWS::S3::S3Object.store(dest, open(File.join(dir, newest)), backup_bucket)
137
+ end
138
+
139
+ tdate = Date.today - age
140
+ threshold = Time.local(tdate.year, tdate.month, tdate.day)
141
+ puts "Cleaning backups older than #{age} days"
142
+ Dir["#{dir}/*"].each do |file|
143
+ if File.mtime(file) < threshold
144
+ puts "Deleting #{file}"
145
+ FileUtils.rm_f(file)
146
+ end
147
+ end
148
+
149
+ if backup_bucket
150
+ puts "Cleaning S3 backups older than #{age} days from: #{backup_bucket}:#{s3_prefix}"
151
+ AWS::S3::Bucket.objects(backup_bucket, :prefix => s3_prefix).clone.each do |obj|
152
+ if Time.parse(obj.about["last-modified"]) < threshold
153
+ puts "Deleting #{obj.key}"
154
+ obj.delete
155
+ end
156
+ end
157
+ end
158
+ end
159
+
160
+ desc <<-DESC
161
+ Backup database to given backup directory
162
+ The following arguments affect behavior:
163
+ BACKUP_DIR (required): Directory where db backups will be stored
164
+ BACKUP_AGE (3): Delete rotated logs older than this many days in the past
165
+ DBUSER (required) User to connect to the db as
166
+ DBPASS (optional): Pass to connect to the db with
167
+ DBHOST (required): Host where the db is
168
+ DBNAME (required): Database name to backup
169
+ DESC
170
+ task :backup_db do
171
+ dir = get_env('BACKUP_DIR', true)
172
+ age = (get_env('BACKUP_AGE') || 3).to_i
173
+ time_stamp = Time.now.strftime("%Y-%m-%d_%H-%M")
174
+ backup_file = "#{dir}/#{RUBBER_ENV}_dump_#{time_stamp}.sql.gz"
175
+ FileUtils.mkdir_p(File.dirname(backup_file))
176
+
177
+ user = get_env('DBUSER', true)
178
+ pass = get_env('DBPASS')
179
+ pass = nil if pass.strip.size == 0
180
+ host = get_env('DBHOST', true)
181
+ name = get_env('DBNAME', true)
182
+
183
+ raise "No db_backup_cmd defined in rubber.yml, cannot backup!" unless rubber_env.db_backup_cmd
184
+ db_backup_cmd = rubber_env.db_backup_cmd.gsub(/%([^%]+)%/, '#{\1}')
185
+ db_backup_cmd = eval('%Q{' + db_backup_cmd + '}')
186
+
187
+ puts "Backing up database with command:"
188
+ sh db_backup_cmd
189
+ puts "Created backup: #{backup_file}"
190
+
191
+ s3_prefix = "db/"
192
+ backup_bucket = cloud_provider.backup_bucket
193
+ if backup_bucket
194
+ init_s3
195
+ unless AWS::S3::Bucket.list.find { |b| b.name == backup_bucket }
196
+ AWS::S3::Bucket.create(backup_bucket)
197
+ end
198
+ dest = "#{s3_prefix}#{File.basename(backup_file)}"
199
+ puts "Saving db backup to S3: #{backup_bucket}:#{dest}"
200
+ AWS::S3::S3Object.store(dest, open(backup_file), backup_bucket)
201
+ end
202
+
203
+ tdate = Date.today - age
204
+ threshold = Time.local(tdate.year, tdate.month, tdate.day)
205
+ puts "Cleaning backups older than #{age} days"
206
+ Dir["#{dir}/*"].each do |file|
207
+ if File.mtime(file) < threshold
208
+ puts "Deleting #{file}"
209
+ FileUtils.rm_f(file)
210
+ end
211
+ end
212
+
213
+ if backup_bucket
214
+ puts "Cleaning S3 backups older than #{age} days from: #{backup_bucket}:#{s3_prefix}"
215
+ AWS::S3::Bucket.objects(backup_bucket, :prefix => s3_prefix).clone.each do |obj|
216
+ if Time.parse(obj.about["last-modified"]) < threshold
217
+ puts "Deleting #{obj.key}"
218
+ obj.delete
219
+ end
220
+ end
221
+ end
222
+ end
223
+
224
+ desc <<-DESC
225
+ Restores a database backup from s3.
226
+ This tries to find the last backup made or the s3 object identified by the
227
+ key FILENAME
228
+ The following arguments affect behavior:
229
+ FILENAME (optional): key of S3 object to use
230
+ DBUSER (required) User to connect to the db as
231
+ DBPASS (optional): Pass to connect to the db with
232
+ DBHOST (required): Host where the db is
233
+ DBNAME (required): Database name to backup
234
+ DESC
235
+ task :restore_db_s3 do
236
+ file = get_env('FILENAME')
237
+ user = get_env('DBUSER', true)
238
+ pass = get_env('DBPASS')
239
+ pass = nil if pass && pass.strip.size == 0
240
+ host = get_env('DBHOST', true)
241
+ name = get_env('DBNAME', true)
242
+
243
+ raise "No db_restore_cmd defined in rubber.yml" unless rubber_env.db_restore_cmd
244
+ db_restore_cmd = rubber_env.db_restore_cmd.gsub(/%([^%]+)%/, '#{\1}')
245
+ db_restore_cmd = eval('%Q{' + db_restore_cmd + '}')
246
+
247
+ # try to fetch a matching file from s3 (if backup_bucket given)
248
+ backup_bucket = cloud_provider.backup_bucket
249
+ raise "No backup_bucket defined in rubber.yml" unless backup_bucket
250
+ if (init_s3 &&
251
+ AWS::S3::Bucket.list.find { |b| b.name == backup_bucket })
252
+ s3objects = AWS::S3::Bucket.find(backup_bucket,
253
+ :prefix => 'db/')
254
+ if file
255
+ puts "trying to fetch #{file} from s3"
256
+ data = s3objects.detect { |o| file == o.key }
257
+ else
258
+ puts "trying to fetch last modified s3 backup"
259
+ data = s3objects.max {|a,b| a.about["last-modified"] <=> b.about["last-modified"] }
260
+ end
261
+ end
262
+ raise "could not access backup file via s3" unless data
263
+
264
+ puts "piping restore data to command [#{db_restore_cmd}]"
265
+ IO.popen(db_restore_cmd, mode='w') do |p|
266
+ data.value do |segment|
267
+ p.write segment
268
+ end
269
+ end
270
+
271
+ end
272
+
273
+ def get_env(name, required=false)
274
+ value = ENV[name]
275
+ raise("#{name} is required, pass using environment") if required && ! value
276
+ return value
277
+ end
278
+
279
+ end
@@ -0,0 +1,72 @@
1
+
2
+
3
+ module Rubber
4
+ module Util
5
+
6
+ def self.symbolize_keys(map)
7
+ map.inject({}) do |options, (key, value)|
8
+ options[key.to_sym || key] = value
9
+ options
10
+ end
11
+ end
12
+
13
+ def self.stringify(val)
14
+ case val
15
+ when String
16
+ val
17
+ when Hash
18
+ val.inject({}) {|h, a| h[stringify(a[0])] = stringify(a[1]); h}
19
+ when Enumerable
20
+ val.collect {|v| stringify(v)}
21
+ else
22
+ val.to_s
23
+ end
24
+
25
+ end
26
+
27
+ # Opens the file for writing by root
28
+ def self.sudo_open(path, perms, &block)
29
+ open("|sudo tee #{path} > /dev/null", perms, &block)
30
+ end
31
+
32
+ def self.is_rails?
33
+ File.exist?(File.join(RUBBER_ROOT, 'config', 'boot.rb'))
34
+ end
35
+
36
+ def self.is_rails2?
37
+ defined?(Rails) && defined?(Rails::VERSION) && Rails::VERSION::MAJOR == 2
38
+ end
39
+
40
+ def self.is_rails3?
41
+ defined?(Rails) && defined?(Rails::VERSION) && Rails::VERSION::MAJOR == 3
42
+ end
43
+
44
+ def self.is_bundler?
45
+ File.exist?(File.join(RUBBER_ROOT, 'Gemfile'))
46
+ end
47
+
48
+ def self.rubber_as_plugin?
49
+ File.exist?(File.join(RUBBER_ROOT, 'vendor/plugins/rubber'))
50
+ end
51
+
52
+ def self.prompt(name, desc, required=false, default=nil)
53
+ value = ENV.delete(name)
54
+ msg = "#{desc}"
55
+ msg << " [#{default}]" if default
56
+ msg << ": "
57
+ unless value
58
+ print msg
59
+ value = gets
60
+ end
61
+ value = value.size == 0 ? default : value
62
+ self.fatal "#{name} is required, pass using environment or enter at prompt" if required && ! value
63
+ return value
64
+ end
65
+
66
+ def self.fatal(msg, code=1)
67
+ puts msg
68
+ exit code
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,6 @@
1
+ # this file just makes it easy to refer to rubber config
2
+ # variables in your apps's config'
3
+ #
4
+
5
+ require "rubber"
6
+ Rubber::initialize(Rails.root, Rails.env)
@@ -0,0 +1,144 @@
1
+ require 'rubygems'
2
+ gem 'test-unit'
3
+
4
+ require 'test/unit'
5
+ require 'tempfile'
6
+ require File.expand_path(File.join(__FILE__, '..', 'test_helper'))
7
+
8
+ class EnvironmentTest < Test::Unit::TestCase
9
+ include Rubber::Configuration
10
+
11
+ def test_known_roles
12
+ env = Rubber::Configuration::Environment.new("#{File.dirname(__FILE__)}/fixtures/basic")
13
+ assert_equal ['role1', 'role2'], env.known_roles, "list of know roles not correct"
14
+ end
15
+
16
+ def test_env
17
+ env = Rubber::Configuration::Environment.new("#{File.dirname(__FILE__)}/fixtures/basic")
18
+ e = env.bind()
19
+ assert_equal 'val1', e['var1'], 'env not retrieving right val'
20
+ assert_equal 'val2', e['var2'], 'env not retrieving right val'
21
+ assert_equal 'val1', e.var1, 'env not retrieving right val for method missing'
22
+ assert_equal 'val2', e.var2, 'env not retrieving right val for method missing'
23
+
24
+ assert_equal 'val3', e.var3, 'env not retrieving right val for config in supplemental file'
25
+
26
+ e = env.bind('role1', 'nohost')
27
+ assert_equal 'val1', e['var1'], 'env not retrieving right val'
28
+ assert_equal 'role1val2', e['var2'], 'env not retrieving right val'
29
+ assert_equal 'val1', e.var1, 'env not retrieving right val for method missing'
30
+ assert_equal 'role1val2', e.var2, 'env not retrieving right val for method missing'
31
+
32
+ e = env.bind('role1', 'host1')
33
+ assert_equal 'val1', e['var1'], 'env not retrieving right val'
34
+ assert_equal 'host1val2', e['var2'], 'env not retrieving right val'
35
+ assert_equal 'val1', e.var1, 'env not retrieving right val for method missing'
36
+ assert_equal 'host1val2', e.var2, 'env not retrieving right val for method missing'
37
+
38
+ e = env.bind('norole', 'host1')
39
+ assert_equal 'val1', e['var1'], 'env not retrieving right val'
40
+ assert_equal 'host1val2', e['var2'], 'env not retrieving right val'
41
+ assert_equal 'val1', e.var1, 'env not retrieving right val for method missing'
42
+ assert_equal 'host1val2', e.var2, 'env not retrieving right val for method missing'
43
+ end
44
+
45
+ def test_host_override
46
+ env = Rubber::Configuration::Environment.new("#{File.dirname(__FILE__)}/fixtures/basic")
47
+ e = env.bind('norole', 'host2')
48
+ assert_equal 'host2val3', e['var3'], 'env not retrieving right val'
49
+ assert_equal %w[host2val4a host2val4b], e['var4'], 'env not retrieving right val'
50
+ assert_equal [{'var51a' => 'val51a', 'var52a' => 'val52a'}, {'var53' => 'val53'}, {'var54' => 'val54'}], e['var5'], 'env not retrieving right val'
51
+ end
52
+
53
+ def test_combine
54
+ env = Rubber::Configuration::Environment
55
+ assert_equal "new", env.combine("old", "new"), "Last should win for scalar combine"
56
+ assert_equal 5, env.combine(1, 5), "Last should win for scalar combine"
57
+ assert_equal [1, 2, 3, 4], env.combine([1, 2, 3], [3, 4]), "Arrays should be unioned when combined"
58
+ assert_equal({1 => "1", 2 => "2", 3 => "3", 4 => "4"}, env.combine({1 => "1", 2 => "2"}, {3 => "3", 4 => "4"}), "Maps should be unioned when combined")
59
+ assert_equal({1 => "2"}, env.combine({1 => "1"}, {1 => "2"}), "Last should win for scalars in maps when combined")
60
+ assert_equal({1 => {1 => "1", 2 => "2"}}, env.combine({1 => {1 => "1"}}, {1 => {2 => "2"}}), "Maps should be unioned recursively when combined")
61
+ end
62
+
63
+ def test_expansion
64
+ env = Rubber::Configuration::Environment.new("#{File.dirname(__FILE__)}/fixtures/expansion")
65
+ e = env.bind()
66
+ assert_equal 'val1', e['var1']
67
+ assert_equal 'val2', e['var2']
68
+ assert_equal 'val1', e['var3']
69
+ assert_equal '4 is val2', e['var4']
70
+ assert_equal 'val1', e['var5']
71
+ assert_equal %w[lv1 lv2 val1], e['list1']
72
+ expected = {'mk1' => 'mv1', 'mk2' => 'mv2', 'mk3' => 'val2'}
73
+ e.map1.each do |k, v|
74
+ assert_equal expected[k], v
75
+ end
76
+
77
+ e = env.bind('role1', 'nohost')
78
+ assert_equal 'role1val1', e['var1']
79
+ assert_equal 'role1val1', e['var3']
80
+ assert_equal %w[lv1 lv2 role1val1 role1lv1 role1val2], e['list1']
81
+
82
+ e = env.bind('role1', 'host1')
83
+ assert_equal 'host1val1', e['var1']
84
+ assert_equal 'host1val1', e['var3']
85
+ assert_equal %w[lv1 lv2 host1val1 role1lv1 host1val2 host1lv1], e['list1'] # lists are additive
86
+
87
+ e = env.bind('norole', 'host1')
88
+ assert_equal 'host1val1', e['var1']
89
+ assert_equal 'host1val1', e['var3']
90
+ assert_equal %w[lv1 lv2 host1val1 host1lv1 host1val2], e['list1']
91
+ end
92
+
93
+ def test_bool_expansion
94
+ env = Rubber::Configuration::Environment.new("#{File.dirname(__FILE__)}/fixtures/expansion")
95
+ e = env.bind()
96
+ assert_equal true, e['truevar']
97
+ assert_equal false, e['falsevar']
98
+ assert_equal true, e['truevar_exp']
99
+ assert 'true' != e['truevar_exp']
100
+ assert_equal false, e['falsevar_exp']
101
+ assert 'false' != e['falsevar_exp']
102
+ assert_equal 'true thing', e['faketruevar_exp']
103
+ end
104
+
105
+ def test_secret_env
106
+ env = Rubber::Configuration::Environment.new("#{File.dirname(__FILE__)}/fixtures/basic")
107
+ e = env.bind()
108
+ assert_nil e['rubber_secret'], 'env should not have secret set'
109
+
110
+ fixture_dir = File.expand_path("#{File.dirname(__FILE__)}/fixtures/secret")
111
+ env = Rubber::Configuration::Environment.new(fixture_dir)
112
+ e = env.bind()
113
+ assert_equal "#{fixture_dir}/secret.yml", e['rubber_secret'], 'env should have secret set'
114
+ assert_equal "secret_val", e['secret_key'], 'env should have gotten setting from secret file'
115
+ end
116
+
117
+ def test_nested_ref
118
+ env = Rubber::Configuration::Environment.new("#{File.dirname(__FILE__)}/fixtures/nested")
119
+ e = env.bind()
120
+ assert_equal 'val1', e.var1, 'env not retrieving right val'
121
+ assert_equal 'val3', e.var2.var3, 'env not retrieving right val'
122
+ assert_equal({'var5' => 'val5'}, e.var2.var4, 'env not retrieving right val')
123
+ assert_equal ['val6a', 'val6b'], e.var2.var6, 'env not retrieving right val'
124
+ assert_equal 'val1', e.var2.var7, 'env not retrieving right val'
125
+ assert_equal 'val3', e.var2.var8, 'env not retrieving right val'
126
+ assert_equal 'val5', e.var2.var9, 'env not retrieving right val'
127
+ end
128
+
129
+ def test_instances_in_expansion
130
+ instance = InstanceItem.new('host1', 'domain.com', [RoleItem.new('role1')], '')
131
+ instance.external_ip = "1.2.3.4"
132
+ instances = Instance.new(Tempfile.new('testforinstanceexpansion').path)
133
+ instances.add(instance)
134
+
135
+ File.expects(:exist?).returns(true)
136
+ YAML.expects(:load_file).returns({'var1' =>'"#{rubber_instances.for_role("role1").first.external_ip}"'})
137
+ Rubber::Configuration.expects(:rubber_instances).returns(instances)
138
+ env = Rubber::Configuration::Environment.new(nil)
139
+ e = env.bind()
140
+
141
+ assert_equal "\"1.2.3.4\"", e['var1']
142
+ end
143
+
144
+ end