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,44 @@
1
+ namespace :rubber do
2
+
3
+ #desc <<-DESC
4
+ # Sets up the network load balancers
5
+ #DESC
6
+ #required_task :setup_load_balancers do
7
+ # setup_load_balancers()
8
+ #end
9
+ #
10
+ #desc <<-DESC
11
+ # Describes the network load balancers
12
+ #DESC
13
+ #required_task :describe_load_balancers do
14
+ # lbs = cloud.describe_load_balancers()
15
+ # pp lbs
16
+ #end
17
+
18
+ def setup_load_balancers
19
+ # OPTIONAL: Automatically provision and assign instances to a Cloud provided
20
+ # load balancer.
21
+ #load_balancers:
22
+ # my_lb_name:
23
+ # listeners:
24
+ # - protocol: http
25
+ # port: 80
26
+ # instance_port: 8080
27
+ # - protocol: tcp
28
+ # port: 443
29
+ # instance_port: 8080
30
+ # target_roles: [app]
31
+ #
32
+ #isolate_load_balancers: true
33
+
34
+
35
+
36
+ # get remote lbs
37
+ # for each local not in remote, add it
38
+ # get all zones for all instances for roles, and make sure in lb
39
+ # warn if lb not balanced (count of instances per zone is equal)
40
+ # for each local that is in remote, sync listeners and zones
41
+ # for each remote not in local, remove it
42
+ end
43
+
44
+ end
@@ -0,0 +1,189 @@
1
+ namespace :rubber do
2
+
3
+ desc <<-DESC
4
+ Sets up the network security groups
5
+ All defined groups will be created, and any not defined will be removed.
6
+ Likewise, rules within a group will get created, and those not will be removed
7
+ DESC
8
+ required_task :setup_security_groups do
9
+ setup_security_groups()
10
+ end
11
+
12
+ desc <<-DESC
13
+ Describes the network security groups
14
+ DESC
15
+ required_task :describe_security_groups do
16
+ groups = cloud.describe_security_groups()
17
+ groups.each do |group|
18
+ puts "#{group[:name]}, #{group[:description]}"
19
+ group[:permissions].each do |perm|
20
+ puts " protocol: #{perm[:protocol]}"
21
+ puts " from_port: #{perm[:from_port]}"
22
+ puts " to_port: #{perm[:to_port]}"
23
+ puts " source_groups: #{perm[:source_groups].collect {|g| g[:name]}.join(", ") }" if perm[:source_groups]
24
+ puts " source_ips: #{perm[:source_ips].join(", ") }" if perm[:source_ips]
25
+ puts "\n"
26
+ end if group[:permissions]
27
+ puts "\n"
28
+ end
29
+ end
30
+
31
+
32
+ def get_assigned_security_groups(host=nil, roles=[])
33
+ env = rubber_cfg.environment.bind(roles, host)
34
+ security_groups = env.assigned_security_groups
35
+ if env.auto_security_groups
36
+ security_groups << host
37
+ security_groups += roles
38
+ end
39
+ security_groups = security_groups.uniq.compact.reject {|x| x.empty? }
40
+ security_groups = security_groups.collect {|x| isolate_group_name(x) } if env.isolate_security_groups
41
+ return security_groups
42
+ end
43
+
44
+ def setup_security_groups(host=nil, roles=[])
45
+ env = rubber_cfg.environment.bind(roles, host)
46
+ security_group_defns = env.security_groups
47
+ if env.auto_security_groups
48
+ sghosts = (rubber_instances.collect{|ic| ic.name } + [host]).uniq.compact
49
+ sgroles = (rubber_instances.all_roles + roles).uniq.compact
50
+ security_group_defns = inject_auto_security_groups(security_group_defns, sghosts, sgroles)
51
+ sync_security_groups(security_group_defns)
52
+ else
53
+ sync_security_groups(security_group_defns)
54
+ end
55
+ end
56
+
57
+ def inject_auto_security_groups(groups, hosts, roles)
58
+ hosts.each do |name|
59
+ group_name = name
60
+ groups[group_name] ||= {'description' => "Rubber automatic security group for host: #{name}", 'rules' => []}
61
+ end
62
+ roles.each do |name|
63
+ group_name = name
64
+ groups[group_name] ||= {'description' => "Rubber automatic security group for role: #{name}", 'rules' => []}
65
+ end
66
+ return groups
67
+ end
68
+
69
+ def isolate_prefix
70
+ return "#{rubber_env.app_name}_#{RUBBER_ENV}_"
71
+ end
72
+
73
+ def isolate_group_name(group_name)
74
+ new_name = "#{isolate_prefix}#{group_name}"
75
+ return new_name
76
+ end
77
+
78
+ def isolate_groups(groups)
79
+ renamed = {}
80
+ groups.each do |name, group|
81
+ new_name = name =~ /^#{isolate_prefix}/ ? name : isolate_group_name(name)
82
+ new_group = Marshal.load(Marshal.dump(group))
83
+ new_group['rules'].each do |rule|
84
+ old_ref_name = rule['source_group_name']
85
+ if old_ref_name && old_ref_name !~ /^#{isolate_prefix}/
86
+ rule['source_group_name'] = isolate_group_name(old_ref_name)
87
+ end
88
+ end
89
+ renamed[new_name] = new_group
90
+ end
91
+ return renamed
92
+ end
93
+
94
+ def sync_security_groups(groups)
95
+ return unless groups
96
+
97
+ groups = Rubber::Util::stringify(groups)
98
+ groups = isolate_groups(groups) if rubber_env.isolate_security_groups
99
+ group_keys = groups.keys.clone()
100
+
101
+ # For each group that does already exist in cloud
102
+ cloud_groups = cloud.describe_security_groups()
103
+ cloud_groups.each do |cloud_group|
104
+ group_name = cloud_group[:name]
105
+
106
+ # skip those groups that don't belong to this project/env
107
+ next if rubber_env.isolate_security_groups && group_name !~ /^#{isolate_prefix}/
108
+
109
+ if group_keys.delete(group_name)
110
+ # sync rules
111
+ logger.debug "Security Group already in cloud, syncing rules: #{group_name}"
112
+ group = groups[group_name]
113
+ rules = group['rules'].clone
114
+ rule_maps = []
115
+
116
+ # first collect the rule maps from the request (group/user pairs are duplicated for tcp/udp/icmp,
117
+ # so we need to do this up frnot and remove duplicates before checking against the local rubber rules)
118
+ cloud_group[:permissions].each do |rule|
119
+ if rule[:source_groups]
120
+ rule.source_groups.each do |source_group|
121
+ rule_map = {:source_group_name => source_group[:name], :source_group_account => source_group[:account]}
122
+ rule_map = Rubber::Util::stringify(rule_map)
123
+ rule_maps << rule_map unless rule_maps.include?(rule_map)
124
+ end
125
+ else
126
+ rule_map = Rubber::Util::stringify(rule)
127
+ rule_maps << rule_map unless rule_maps.include?(rule_map)
128
+ end
129
+ end if cloud_group[:permissions]
130
+ # For each rule, if it exists, do nothing, otherwise remove it as its no longer defined locally
131
+ rule_maps.each do |rule_map|
132
+ if rules.delete(rule_map)
133
+ # rules match, don't need to do anything
134
+ # logger.debug "Rule in sync: #{rule_map.inspect}"
135
+ else
136
+ # rules don't match, remove them from cloud and re-add below
137
+ answer = Capistrano::CLI.ui.ask("Rule '#{rule_map.inspect}' exists in cloud, but not locally, remove from cloud? [y/N]?: ")
138
+ rule_map = Rubber::Util::symbolize_keys(rule_map)
139
+ if rule_map[:source_group_name]
140
+ cloud.remove_security_group_rule(group_name, nil, nil, nil, {:name => rule_map[:source_group_name], :account => rule_map[:source_group_account]})
141
+ else
142
+ rule_map[:source_ips].each do |source_ip|
143
+ cloud.remove_security_group_rule(group_name, rule_map[:protocol], rule_map[:from_port], rule_map[:to_port], source_ip)
144
+ end if rule_map[:source_ips] && answer =~ /^y/
145
+ end
146
+ end
147
+ end
148
+
149
+ rules.each do |rule_map|
150
+ # create non-existing rules
151
+ logger.debug "Missing rule, creating: #{rule_map.inspect}"
152
+ rule_map = Rubber::Util::symbolize_keys(rule_map)
153
+ if rule_map[:source_group_name]
154
+ cloud.add_security_group_rule(group_name, nil, nil, nil, {:name => rule_map[:source_group_name], :account => rule_map[:source_group_account]})
155
+ else
156
+ rule_map[:source_ips].each do |source_ip|
157
+ cloud.add_security_group_rule(group_name, rule_map[:protocol], rule_map[:from_port], rule_map[:to_port], source_ip)
158
+ end if rule_map[:source_ips]
159
+ end
160
+ end
161
+ else
162
+ # delete group
163
+ answer = Capistrano::CLI.ui.ask("Security group '#{group_name}' exists in cloud but not locally, remove from cloud? [y/N]: ")
164
+ cloud.destroy_security_group(group_name) if answer =~ /^y/
165
+ end
166
+ end
167
+
168
+ # For each group that didnt already exist in cloud
169
+ group_keys.each do |group_name|
170
+ group = groups[group_name]
171
+ logger.debug "Creating new security group: #{group_name}"
172
+ # create each group
173
+ cloud.create_security_group(group_name, group['description'])
174
+ # create rules for group
175
+ group['rules'].each do |rule_map|
176
+ logger.debug "Creating new rule: #{rule_map.inspect}"
177
+ rule_map = Rubber::Util::symbolize_keys(rule_map)
178
+ if rule_map[:source_group_name]
179
+ cloud.add_security_group_rule(group_name, nil, nil, nil, {:name => rule_map[:source_group_name], :account => rule_map[:source_group_account]})
180
+ else
181
+ rule_map[:source_ips].each do |source_ip|
182
+ cloud.add_security_group_rule(group_name, rule_map[:protocol], rule_map[:from_port], rule_map[:to_port], source_ip)
183
+ end if rule_map[:source_ips]
184
+ end
185
+ end
186
+ end
187
+ end
188
+
189
+ end
@@ -0,0 +1,534 @@
1
+ namespace :rubber do
2
+
3
+ desc <<-DESC
4
+ Bootstraps instances by setting timezone, installing packages and gems
5
+ DESC
6
+ task :bootstrap do
7
+ link_bash
8
+ set_timezone
9
+ enable_multiverse
10
+ upgrade_packages
11
+ install_packages
12
+ setup_volumes
13
+ setup_gem_sources
14
+ install_gems
15
+ deploy.setup
16
+ end
17
+
18
+ # Sets up instance to allow root access (e.g. recent canonical AMIs)
19
+ def enable_root_ssh(ip, initial_ssh_user)
20
+ old_user = user
21
+ begin
22
+ set :user, initial_ssh_user
23
+
24
+ task :_allow_root_ssh, :hosts => ip do
25
+ rsudo "cp /home/#{initial_ssh_user}/.ssh/authorized_keys /root/.ssh/"
26
+ end
27
+
28
+ begin
29
+ _allow_root_ssh
30
+ rescue ConnectionError => e
31
+ if e.message =~ /Net::SSH::AuthenticationFailed/
32
+ logger.info "Can't connect as user #{initial_ssh_user} to #{ip}, assuming root allowed"
33
+ else
34
+ sleep 2
35
+ logger.info "Failed to connect to #{ip}, retrying"
36
+ retry
37
+ end
38
+ end
39
+ ensure
40
+ set :user, old_user
41
+ end
42
+
43
+ end
44
+
45
+ # Forces a direct connection
46
+ def direct_connection(ip)
47
+ task_name = "_direct_connection_#{ip}_#{rand(1000)}"
48
+ task task_name, :hosts => ip do
49
+ yield
50
+ end
51
+
52
+ begin
53
+ send task_name
54
+ rescue ConnectionError => e
55
+ sleep 2
56
+ logger.info "Failed to connect to #{ip}, retrying"
57
+ retry
58
+ end
59
+ end
60
+
61
+ desc <<-DESC
62
+ Sets up aliases for instance hostnames based on contents of instance.yml.
63
+ Generates /etc/hosts for local/remote machines and sets hostname on
64
+ remote instances, and sets values in dynamic dns entries
65
+ DESC
66
+ required_task :setup_aliases do
67
+ setup_local_aliases
68
+ setup_remote_aliases
69
+ setup_dns_aliases
70
+ end
71
+
72
+ desc <<-DESC
73
+ Sets up local aliases for instance hostnames based on contents of instance.yml.
74
+ Generates/etc/hosts for local machine
75
+ DESC
76
+ required_task :setup_local_aliases do
77
+ hosts_file = '/etc/hosts'
78
+
79
+ # Generate /etc/hosts contents for the local machine from instance config
80
+ delim = "## rubber config #{rubber_env.domain} #{RUBBER_ENV}"
81
+ local_hosts = delim + "\n"
82
+ rubber_instances.each do |ic|
83
+ # don't add unqualified hostname in local hosts file since user may be
84
+ # managing multiple domains with same aliases
85
+ hosts_data = [ic.full_name, ic.external_host, ic.internal_host].join(' ')
86
+ local_hosts << ic.external_ip << ' ' << hosts_data << "\n"
87
+ end
88
+ local_hosts << delim << "\n"
89
+
90
+ # Write out the hosts file for this machine, use sudo
91
+ filtered = File.read(hosts_file).gsub(/^#{delim}.*^#{delim}\n?/m, '')
92
+ logger.info "Writing out aliases into local machines #{hosts_file}, sudo access needed"
93
+ Rubber::Util::sudo_open(hosts_file, 'w') do |f|
94
+ f.write(filtered)
95
+ f.write(local_hosts)
96
+ end
97
+ end
98
+
99
+ desc <<-DESC
100
+ Sets up aliases in dynamic dns provider for instance hostnames based on contents of instance.yml.
101
+ DESC
102
+ required_task :setup_dns_aliases do
103
+ rubber_instances.each do |ic|
104
+ update_dyndns(ic)
105
+ end
106
+ end
107
+
108
+ desc <<-DESC
109
+ Sets up the additional dns records supplied in the dns_records config in rubber.yml
110
+ DESC
111
+ required_task :setup_dns_records do
112
+ records = rubber_env.dns_records
113
+ if records && rubber_env.dns_provider
114
+ provider = Rubber::Dns::get_provider(rubber_env.dns_provider, rubber_env)
115
+
116
+ # collect the round robin records (those with the same host/domain/type)
117
+ rr_records = []
118
+ records.each_with_index do |record, i|
119
+ m = records.find_all {|r| record['host'] == r['host'] && record['domain'] == r['domain'] && record['type'] == r['type']}
120
+ m = m.sort {|a,b| a.object_id <=> b.object_id}
121
+ rr_records << m if m.size > 1 && ! rr_records.include?(m)
122
+ end
123
+
124
+ # simple records are those that aren't round robin ones
125
+ simple_records = records - rr_records.flatten
126
+
127
+ # for each simple record, create or update as necessary
128
+ simple_records.each do |record|
129
+ matching = provider.find_host_records(:host => record['host'], :domain =>record['domain'], :type => record['type'])
130
+ if matching.size > 1
131
+ msg = "Multiple records in dns provider, but not in rubber.yml\n"
132
+ msg << "Round robin records need to be in both, or neither.\n"
133
+ msg << "Please fix manually:\n"
134
+ msg << matching.pretty_inspect
135
+ fatal(msg)
136
+ end
137
+
138
+ record = provider.setup_opts(record)
139
+ if matching.size == 1
140
+ match = matching.first
141
+ if provider.host_records_equal?(record, match)
142
+ logger.info "Simple dns record already up to date: #{record[:host]}.#{record[:domain]}:#{record[:type]} => #{record[:data]}"
143
+ else
144
+ logger.info "Updating simple dns record: #{record[:host]}.#{record[:domain]}:#{record[:type]} => #{record[:data]}"
145
+ provider.update_host_record(match, record)
146
+ end
147
+ else
148
+ logger.info "Creating simple dns record: #{record[:host]}.#{record[:domain]}:#{record[:type]} => #{record[:data]}"
149
+ provider.create_host_record(record)
150
+ end
151
+ end
152
+
153
+ # group round robin records
154
+ rr_records.each do |rr_group|
155
+ host = rr_group.first['host']
156
+ domain = rr_group.first['domain']
157
+ type = rr_group.first['type']
158
+ matching = provider.find_host_records(:host => host, :domain => domain, :type => type)
159
+
160
+ # remove from consideration the local records that are the same as remote ones
161
+ matching.clone.each do |r|
162
+ rr_group.delete_if {|rg| provider.host_records_equal?(r, rg) }
163
+ matching.delete_if {|rg| provider.host_records_equal?(r, rg) }
164
+ end
165
+ if rr_group.size == 0 && matching.size == 0
166
+ logger.info "Round robin dns records already up to date: #{host}.#{domain}:#{type}"
167
+ end
168
+
169
+ # create the local records that don't exist remotely
170
+ rr_group.each do |r|
171
+ r = provider.setup_opts(r)
172
+ logger.info "Creating round robin dns record: #{r[:host]}.#{r[:domain]}:#{r[:type]} => #{r[:data]}"
173
+ provider.create_host_record(r)
174
+ end
175
+
176
+ # remove the remote records that don't exist locally
177
+ matching.each do |r|
178
+ logger.info "Removing round robin dns record: #{r[:host]}.#{r[:domain]}:#{r[:type]} => #{r[:data]}"
179
+ provider.destroy_host_record(r)
180
+ end
181
+ end
182
+ end
183
+ end
184
+
185
+ desc <<-DESC
186
+ Sets up aliases for instance hostnames based on contents of instance.yml.
187
+ Generates /etc/hosts for remote machines and sets hostname on remote instances
188
+ DESC
189
+ task :setup_remote_aliases do
190
+ hosts_file = '/etc/hosts'
191
+
192
+ # Generate /etc/hosts contents for the remote instance from instance config
193
+ delim = "## rubber config"
194
+ delim = "#{delim} #{RUBBER_ENV}"
195
+ remote_hosts = delim + "\n"
196
+ rubber_instances.each do |ic|
197
+ hosts_data = [ic.name, ic.full_name, ic.external_host, ic.internal_host].join(' ')
198
+ remote_hosts << ic.internal_ip << ' ' << hosts_data << "\n"
199
+ end
200
+ remote_hosts << delim << "\n"
201
+ if rubber_instances.size > 0
202
+ # write out the hosts file for the remote instances
203
+ # NOTE that we use "capture" to get the existing hosts
204
+ # file, which only grabs the hosts file from the first host
205
+ filtered = (capture "cat #{hosts_file}").gsub(/^#{delim}.*^#{delim}\n?/m, '')
206
+ filtered = filtered + remote_hosts
207
+ # Put the generated hosts back on remote instance
208
+ put filtered, hosts_file
209
+
210
+ # Setup hostname on instance so shell, etcs have nice display
211
+ rsudo "echo $CAPISTRANO:HOST$ > /etc/hostname && hostname $CAPISTRANO:HOST$"
212
+ # Newer ubuntus ec2-init script always resets hostname, so prevent it
213
+ rsudo "mkdir -p /etc/ec2-init && echo compat=0 > /etc/ec2-init/is-compat-env"
214
+ end
215
+
216
+ # TODO
217
+ # /etc/resolv.conf to add search domain
218
+ # ~/.ssh/options to setup user/host/key aliases
219
+ end
220
+
221
+ desc <<-DESC
222
+ Update to the newest versions of all packages/gems.
223
+ DESC
224
+ task :update do
225
+ upgrade_packages
226
+ update_gems
227
+ end
228
+
229
+ desc <<-DESC
230
+ Upgrade to the newest versions of all Ubuntu packages.
231
+ DESC
232
+ task :upgrade_packages do
233
+ package_helper(true)
234
+ end
235
+
236
+ desc <<-DESC
237
+ Upgrade to the newest versions of all rubygems.
238
+ DESC
239
+ task :update_gems do
240
+ gem_helper(true)
241
+ end
242
+
243
+ desc <<-DESC
244
+ Install extra packages and gems.
245
+ DESC
246
+ task :install do
247
+ install_packages
248
+ install_gems
249
+ end
250
+
251
+ desc <<-DESC
252
+ Install Ubuntu packages. Set 'packages' in rubber.yml to \
253
+ be an array of strings.
254
+ DESC
255
+ task :install_packages do
256
+ package_helper(false)
257
+ end
258
+
259
+ desc <<-DESC
260
+ Install ruby gems. Set 'gems' in rubber.yml to \
261
+ be an array of strings.
262
+ DESC
263
+ task :install_gems do
264
+ gem_helper(false)
265
+ end
266
+
267
+ desc <<-DESC
268
+ Install ruby gems defined in Gemfile
269
+ DESC
270
+ after "deploy:update_code", "rubber:install_bundler_gems" if Rubber::Util.is_bundler?
271
+ task :install_bundler_gems do
272
+ # copied from bundler/capistrano in bundler distro
273
+ bundle_dir = fetch(:bundle_dir, " #{fetch(:shared_path)}/bundle")
274
+ bundle_without = [*fetch(:bundle_without, [:development, :test])].compact
275
+ bundle_flags = fetch(:bundle_flags, "--deployment --quiet")
276
+ bundle_gemfile = fetch(:bundle_gemfile, "Gemfile")
277
+ bundle_cmd = fetch(:bundle_cmd, "bundle")
278
+
279
+ args = ["--gemfile #{fetch(:latest_release)}/#{bundle_gemfile}"]
280
+ args << "--path #{bundle_dir}" unless bundle_dir.to_s.empty?
281
+ args << bundle_flags.to_s
282
+ args << "--without #{bundle_without.join(" ")}" unless bundle_without.empty?
283
+
284
+ rsudo "#{bundle_cmd} install #{args.join(' ')}"
285
+ end
286
+
287
+ desc <<-DESC
288
+ Install ruby gems defined in the rails environment.rb
289
+ DESC
290
+ after "rubber:config", "rubber:install_rails_gems" if (Rubber::Util::is_rails2? && !Rubber::Util.is_bundler?)
291
+ task :install_rails_gems do
292
+ rsudo "cd #{current_release} && RAILS_ENV=#{RUBBER_ENV} rake gems:install"
293
+ end
294
+
295
+ desc <<-DESC
296
+ Convenience task for installing your defined set of ruby gems locally.
297
+ DESC
298
+ required_task :install_local_gems do
299
+ fatal("install_local_gems can only be run in development") if RUBBER_ENV != 'development'
300
+ env = rubber_cfg.environment.bind(rubber_cfg.environment.known_roles)
301
+ gems = env['gems']
302
+ expanded_gem_list = []
303
+ gems.each do |gem_spec|
304
+ if gem_spec.is_a?(Array)
305
+ expanded_gem_list << "#{gem_spec[0]}:#{gem_spec[1]}"
306
+ else
307
+ expanded_gem_list << gem_spec
308
+ end
309
+ end
310
+ expanded_gem_list = expanded_gem_list.join(' ')
311
+
312
+ logger.info "Installing gems:#{expanded_gem_list}"
313
+ open("/tmp/gem_helper", "w") {|f| f.write(gem_helper_script)}
314
+ system "ruby /tmp/gem_helper install #{expanded_gem_list}"
315
+ end
316
+
317
+ set :gem_sources_helper_script, <<-'ENDSCRIPT'
318
+ sources = ARGV
319
+
320
+ installed = []
321
+ `gem sources -l`.each_line do |line|
322
+ line = line.strip
323
+ installed << line if line.size > 0 && line =~ /^[^*]/
324
+ end
325
+
326
+ to_install = sources - installed
327
+ to_remove = installed - sources
328
+
329
+ if to_install.size > 0
330
+ to_install.each do |source|
331
+ system "gem sources -a #{source}"
332
+ fail "Unable to add gem sources" if $?.exitstatus > 0
333
+ end
334
+ end
335
+ if to_remove.size > 0
336
+ to_remove.each do |source|
337
+ system "gem sources -r #{source}"
338
+ fail "Unable to remove gem sources" if $?.exitstatus > 0
339
+ end
340
+ end
341
+ ENDSCRIPT
342
+
343
+ desc <<-DESC
344
+ Setup ruby gems sources. Set 'gemsources' in rubber.yml to \
345
+ be an array of URI strings.
346
+ DESC
347
+ task :setup_gem_sources do
348
+ if rubber_env.gemsources
349
+ script = prepare_script 'gem_sources_helper', gem_sources_helper_script, nil
350
+ rsudo "ruby #{script} #{rubber_env.gemsources.join(' ')}"
351
+ end
352
+ end
353
+
354
+ desc <<-DESC
355
+ The ubuntu has /bin/sh linking to dash instead of bash, fix this
356
+ You can override this task if you don't want this to happen
357
+ DESC
358
+ task :link_bash do
359
+ rsudo "ln -sf /bin/bash /bin/sh"
360
+ end
361
+
362
+ desc <<-DESC
363
+ Set the timezone using the value of the variable named timezone. \
364
+ Valid options for timezone can be determined by the contents of \
365
+ /usr/share/zoneinfo, which can be seen here: \
366
+ http://packages.ubuntu.com/cgi-bin/search_contents.pl?searchmode=filelist&word=tzdata&version=gutsy&arch=all&page=1&number=all \
367
+ Remove 'usr/share/zoneinfo/' from the filename, and use the last \
368
+ directory and file as the value. For example 'Africa/Abidjan' or \
369
+ 'posix/GMT' or 'Canada/Eastern'.
370
+ DESC
371
+ task :set_timezone do
372
+ opts = get_host_options('timezone')
373
+ rsudo "echo $CAPISTRANO:VAR$ > /etc/timezone", opts
374
+ rsudo "cp /usr/share/zoneinfo/$CAPISTRANO:VAR$ /etc/localtime", opts
375
+ # restart syslog so that times match timezone
376
+ sudo_script 'restart_syslog', <<-ENDSCRIPT
377
+ if [[ -x /etc/init.d/sysklogd ]]; then
378
+ /etc/init.d/sysklogd restart
379
+ elif [[ -x /etc/init.d/rsyslog ]]; then
380
+ service rsyslog restart
381
+ fi
382
+ ENDSCRIPT
383
+ end
384
+
385
+ desc <<-DESC
386
+ Enable the ubuntu multiverse source for getting packages like
387
+ ec2-ami-tools used for bundling images
388
+ DESC
389
+ task :enable_multiverse do
390
+ sudo_script 'enable_multiverse', <<-ENDSCRIPT
391
+ if ! grep -qc multiverse /etc/apt/sources.list /etc/apt/sources.list.d/* &> /dev/null; then
392
+ cat /etc/apt/sources.list | sed 's/main universe/multiverse/' > /etc/apt/sources.list.d/rubber-multiverse-source.list
393
+ fi
394
+ ENDSCRIPT
395
+ end
396
+
397
+ def update_dyndns(instance_item)
398
+ env = rubber_cfg.environment.bind(instance_item.role_names, instance_item.name)
399
+ if env.dns_provider
400
+ provider = Rubber::Dns::get_provider(env.dns_provider, env)
401
+ provider.update(instance_item.name, instance_item.external_ip)
402
+ end
403
+ end
404
+
405
+ def destroy_dyndns(instance_item)
406
+ env = rubber_cfg.environment.bind(instance_item.role_names, instance_item.name)
407
+ if env.dns_provider
408
+ provider = Rubber::Dns::get_provider(env.dns_provider, env)
409
+ provider.destroy(instance_item.name)
410
+ end
411
+ end
412
+
413
+ def package_helper(upgrade=false)
414
+ opts = get_host_options('packages') do |pkg_list|
415
+ expanded_pkg_list = []
416
+ pkg_list.each do |pkg_spec|
417
+ if pkg_spec.is_a?(Array)
418
+ expanded_pkg_list << "#{pkg_spec[0]}=#{pkg_spec[1]}"
419
+ else
420
+ expanded_pkg_list << pkg_spec
421
+ end
422
+ end
423
+ expanded_pkg_list.join(' ')
424
+ end
425
+
426
+ rsudo "apt-get -q update"
427
+ if upgrade
428
+ rsudo "export DEBIAN_FRONTEND=noninteractive; apt-get -q -o Dpkg::Options::=--force-confold -y --force-yes dist-upgrade"
429
+ else
430
+ rsudo "export DEBIAN_FRONTEND=noninteractive; apt-get -q -o Dpkg::Options::=--force-confold -y --force-yes install $CAPISTRANO:VAR$", opts
431
+ end
432
+ end
433
+
434
+ def custom_package(url_base, name, ver, install_test)
435
+ rubber.sudo_script "install_#{name}", <<-ENDSCRIPT
436
+ if [[ #{install_test} ]]; then
437
+ arch=`uname -m`
438
+ if [ "$arch" = "x86_64" ]; then
439
+ src="#{url_base}/#{name}_#{ver}_amd64.deb"
440
+ else
441
+ src="#{url_base}/#{name}_#{ver}_i386.deb"
442
+ fi
443
+ src_file="${src##*/}"
444
+ wget -qNP /tmp ${src}
445
+ dpkg -i /tmp/${src_file}
446
+ fi
447
+ ENDSCRIPT
448
+ end
449
+
450
+ def handle_gem_prompt(ch, data, str)
451
+ ch[:data] ||= ""
452
+ ch[:data] << data
453
+ if data =~ />\s*$/
454
+ logger.info data
455
+ logger.info "The gem command is asking for a number:"
456
+ choice = STDIN.gets
457
+ ch.send_data(choice)
458
+ else
459
+ logger.info data
460
+ end
461
+ end
462
+
463
+ # Rubygems always installs even if the gem is already installed
464
+ # When providing versions, rubygems fails unless versions are provided for all gems
465
+ # This helper script works around these issues by installing gems only if they
466
+ # aren't already installed, and separates versioned/unversioned into two separate
467
+ # calls to rubygems
468
+ #
469
+ set :gem_helper_script, <<-'ENDSCRIPT'
470
+ gem_cmd = ARGV[0]
471
+ gems = ARGV[1..-1]
472
+ cmd = "gem #{gem_cmd} --no-rdoc --no-ri"
473
+
474
+ to_install = {}
475
+ to_install_ver = {}
476
+ # gem list passed in, possibly with versions, as "gem1 gem2:1.2 gem3"
477
+ gems.each do |gem_spec|
478
+ parts = gem_spec.split(':')
479
+ if parts[1]
480
+ to_install_ver[parts[0]] = parts[1]
481
+ else
482
+ to_install[parts[0]] = true
483
+ end
484
+ end
485
+
486
+ installed = {}
487
+ `gem list --local`.each_line do |line|
488
+ parts = line.scan(/(.*) \((.*)\)/).first
489
+ next unless parts && parts.size == 2
490
+ installed[parts[0]] = parts[1].split(",")
491
+ end
492
+
493
+ to_install.delete_if {|g, v| installed.has_key?(g) } if gem_cmd == 'install'
494
+ to_install_ver.delete_if {|g, v| installed.has_key?(g) && installed[g].include?(v) }
495
+
496
+ # rubygems can only do asingle versioned gem at a time so we need
497
+ # to do the two groups separately
498
+ # install versioned ones first so unversioned don't pull in a newer version
499
+ to_install_ver.each do |g, v|
500
+ system "#{cmd} #{g} -v #{v}"
501
+ fail "Unable to install versioned gem #{g}:#{v}" if $?.exitstatus > 0
502
+ end
503
+ if to_install.size > 0
504
+ gem_list = to_install.keys.join(' ')
505
+ system "#{cmd} #{gem_list}"
506
+ fail "Unable to install gems" if $?.exitstatus > 0
507
+ end
508
+ ENDSCRIPT
509
+
510
+ # Helper for installing gems,allows one to respond to prompts
511
+ def gem_helper(update=false)
512
+ cmd = update ? "update" : "install"
513
+
514
+ opts = get_host_options('gems') do |gem_list|
515
+ expanded_gem_list = []
516
+ gem_list.each do |gem_spec|
517
+ if gem_spec.is_a?(Array)
518
+ expanded_gem_list << "#{gem_spec[0]}:#{gem_spec[1]}"
519
+ else
520
+ expanded_gem_list << gem_spec
521
+ end
522
+ end
523
+ expanded_gem_list.join(' ')
524
+ end
525
+
526
+ if opts.size > 0
527
+ script = prepare_script('gem_helper', gem_helper_script, nil)
528
+ rsudo "ruby #{script} #{cmd} $CAPISTRANO:VAR$", opts do |ch, str, data|
529
+ handle_gem_prompt(ch, data, str)
530
+ end
531
+ end
532
+ end
533
+
534
+ end