nirvdrum-rubber 1.1.7 → 2.0.0.rails3.beta6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (291) hide show
  1. data/CHANGELOG +82 -0
  2. data/VERSION +1 -1
  3. data/bin/vulcanize +10 -33
  4. data/generators/vulcanize/templates/apache/config/rubber/deploy-apache.rb +6 -6
  5. data/generators/vulcanize/templates/apache/config/rubber/role/apache/monit-apache.conf +2 -2
  6. data/generators/vulcanize/templates/apache/config/rubber/role/apache/ports.conf +3 -0
  7. data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache-vhost.conf +29 -16
  8. data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-index.html +1 -1
  9. data/generators/vulcanize/templates/base/Rakefile +19 -0
  10. data/generators/vulcanize/templates/base/config/rubber/common/crontab +6 -1
  11. data/generators/vulcanize/templates/base/config/rubber/common/monit-postfix.conf +2 -2
  12. data/generators/vulcanize/templates/base/config/rubber/common/rubber.profile +3 -4
  13. data/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +28 -49
  14. data/generators/vulcanize/templates/base/config/rubber/deploy-util.rb +97 -0
  15. data/generators/vulcanize/templates/base/config/rubber/rubber-dns.yml +0 -1
  16. data/generators/vulcanize/templates/base/config/rubber/rubber-rvm.yml +25 -0
  17. data/generators/vulcanize/templates/base/config/rubber/rubber.yml +21 -13
  18. data/generators/vulcanize/templates/base/script/cron-runner +1 -1
  19. data/generators/vulcanize/templates/base/templates.rb +1 -0
  20. data/generators/vulcanize/templates/base/templates.yml +5 -0
  21. data/generators/vulcanize/templates/cassandra/config/rubber/deploy-cassandra.rb +88 -0
  22. data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.in.sh +58 -0
  23. data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.yaml +210 -0
  24. data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/log4j-server.properties +45 -0
  25. data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/monit-cassandra.conf +8 -0
  26. data/generators/vulcanize/templates/cassandra/config/rubber/rubber-cassandra.yml +18 -0
  27. data/generators/vulcanize/templates/cassandra/templates.yml +1 -0
  28. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/haproxy/haproxy-mongrel.conf +2 -2
  29. data/generators/vulcanize/templates/{complete_passenger_mysql → complete_passenger}/config/rubber/role/haproxy/haproxy-passenger.conf +2 -2
  30. data/generators/vulcanize/templates/complete_passenger/templates.rb +9 -0
  31. data/generators/vulcanize/templates/complete_passenger/templates.yml +9 -0
  32. data/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +1 -7
  33. data/generators/vulcanize/templates/complete_passenger_postgresql/templates.yml +4 -0
  34. data/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +3 -3
  35. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/my.cnf +1 -1
  36. data/generators/vulcanize/templates/haproxy/config/rubber/deploy-haproxy.rb +5 -5
  37. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +2 -2
  38. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf +8 -3
  39. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslogd-default.conf +4 -0
  40. data/generators/vulcanize/templates/jetty/config/rubber/deploy-jetty.rb +5 -5
  41. data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached.conf +1 -1
  42. data/generators/vulcanize/templates/mongrel/config/rubber/deploy-mongrel.rb +4 -4
  43. data/generators/vulcanize/templates/monit/config/rubber/common/monit.conf +2 -1
  44. data/generators/vulcanize/templates/monit/config/rubber/deploy-monit.rb +5 -4
  45. data/generators/vulcanize/templates/munin/config/rubber/common/monit-munin.conf +2 -2
  46. data/generators/vulcanize/templates/munin/config/rubber/common/munin-node.conf +1 -1
  47. data/generators/vulcanize/templates/munin/config/rubber/common/munin-plugins.conf +4 -2
  48. data/generators/vulcanize/templates/munin/config/rubber/deploy-munin.rb +5 -5
  49. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-plugins.conf +1 -1
  50. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +1 -0
  51. data/generators/vulcanize/templates/munin/config/rubber/rubber-munin.yml +1 -1
  52. data/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +6 -8
  53. data/generators/vulcanize/templates/mysql/config/rubber/common/database.yml +1 -0
  54. data/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +40 -27
  55. data/generators/vulcanize/templates/mysql/config/rubber/role/db/apparmor-mysql.conf +46 -0
  56. data/generators/vulcanize/templates/mysql/config/rubber/role/db/monit-mysql.cnf +2 -2
  57. data/generators/vulcanize/templates/mysql/config/rubber/role/db/my.cnf +2 -6
  58. data/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +2 -1
  59. data/generators/vulcanize/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb +19 -15
  60. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf +2 -2
  61. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf +2 -2
  62. data/generators/vulcanize/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb +3 -3
  63. data/generators/vulcanize/templates/nginx/config/rubber/deploy-nginx.rb +5 -5
  64. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/monit-nginx.conf +2 -2
  65. data/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +10 -1
  66. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +1 -1
  67. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +2 -2
  68. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +1 -1
  69. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +28 -3
  70. data/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +3 -3
  71. data/generators/vulcanize/templates/postgresql/config/rubber/common/database.yml +12 -0
  72. data/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +131 -0
  73. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/crontab +14 -0
  74. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/monit-postgresql.conf +10 -0
  75. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/pg_hba.conf +89 -0
  76. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql-sysctl.conf +6 -0
  77. data/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +504 -0
  78. data/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +45 -0
  79. data/generators/vulcanize/templates/postgresql/templates.yml +1 -0
  80. data/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +8 -7
  81. data/generators/vulcanize/templates/resque/config/initializers/resque.rb +15 -0
  82. data/generators/vulcanize/templates/resque/config/rubber/common/resque.yml +5 -0
  83. data/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +46 -27
  84. data/generators/vulcanize/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf +14 -0
  85. data/generators/vulcanize/templates/resque/config/rubber/role/resque_worker/monit-resque_worker.conf +19 -0
  86. data/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +14 -6
  87. data/generators/vulcanize/templates/resque/script/resque_worker_management.rb +112 -0
  88. data/generators/vulcanize/templates/resque/templates.rb +1 -0
  89. data/generators/vulcanize/templates/sphinx/config/rubber/deploy-sphinx.rb +8 -8
  90. data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf +7 -4
  91. data/generators/vulcanize/vulcanize_generator.rb +139 -49
  92. data/lib/generators/vulcanize/USAGE +6 -0
  93. data/lib/generators/vulcanize/templates/apache/config/rubber/deploy-apache.rb +51 -0
  94. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/deflate.conf +10 -0
  95. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/expires.conf +9 -0
  96. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/headers.conf +6 -0
  97. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/monit-apache.conf +8 -0
  98. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/ports.conf +8 -0
  99. data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/setenvif.conf +52 -0
  100. data/lib/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache-vhost.conf +79 -0
  101. data/lib/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache.auth +7 -0
  102. data/lib/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-index.html +34 -0
  103. data/lib/generators/vulcanize/templates/apache/config/rubber/rubber-apache.yml +6 -0
  104. data/lib/generators/vulcanize/templates/apache/templates.yml +1 -0
  105. data/lib/generators/vulcanize/templates/base/Capfile +14 -0
  106. data/lib/generators/vulcanize/templates/base/Rakefile +19 -0
  107. data/lib/generators/vulcanize/templates/base/config/deploy.rb +55 -0
  108. data/lib/generators/vulcanize/templates/base/config/rubber/common/crontab +22 -0
  109. data/lib/generators/vulcanize/templates/base/config/rubber/common/monit-postfix.conf +8 -0
  110. data/lib/generators/vulcanize/templates/base/config/rubber/common/rubber.profile +13 -0
  111. data/lib/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +63 -0
  112. data/lib/generators/vulcanize/templates/base/config/rubber/deploy-util.rb +97 -0
  113. data/lib/generators/vulcanize/templates/base/config/rubber/rubber-dns.yml +78 -0
  114. data/lib/generators/vulcanize/templates/base/config/rubber/rubber-rvm.yml +25 -0
  115. data/lib/generators/vulcanize/templates/base/config/rubber/rubber.yml +235 -0
  116. data/lib/generators/vulcanize/templates/base/lib/tasks/rubber.rake +15 -0
  117. data/lib/generators/vulcanize/templates/base/script/cron-rake +18 -0
  118. data/lib/generators/vulcanize/templates/base/script/cron-runner +18 -0
  119. data/lib/generators/vulcanize/templates/base/script/cron-sh +67 -0
  120. data/lib/generators/vulcanize/templates/base/templates.rb +1 -0
  121. data/lib/generators/vulcanize/templates/base/templates.yml +6 -0
  122. data/lib/generators/vulcanize/templates/cassandra/config/rubber/deploy-cassandra.rb +88 -0
  123. data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.in.sh +58 -0
  124. data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.yaml +210 -0
  125. data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/log4j-server.properties +45 -0
  126. data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/monit-cassandra.conf +8 -0
  127. data/lib/generators/vulcanize/templates/cassandra/config/rubber/rubber-cassandra.yml +18 -0
  128. data/lib/generators/vulcanize/templates/cassandra/templates.yml +1 -0
  129. data/lib/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/haproxy/haproxy-mongrel.conf +23 -0
  130. data/lib/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/nginx/nginx-mongrel.conf +113 -0
  131. data/lib/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/rubber-complete.yml +41 -0
  132. data/lib/generators/vulcanize/templates/complete_mongrel_mysql/templates.yml +6 -0
  133. data/lib/generators/vulcanize/templates/complete_passenger/config/rubber/role/haproxy/haproxy-passenger.conf +21 -0
  134. data/lib/generators/vulcanize/templates/complete_passenger/config/rubber/rubber-complete.yml +40 -0
  135. data/lib/generators/vulcanize/templates/complete_passenger/templates.rb +9 -0
  136. data/lib/generators/vulcanize/templates/complete_passenger/templates.yml +9 -0
  137. data/lib/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +4 -0
  138. data/lib/generators/vulcanize/templates/complete_passenger_postgresql/templates.yml +4 -0
  139. data/lib/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +72 -0
  140. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/cruise +40 -0
  141. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/my.cnf +165 -0
  142. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/production.rb +8 -0
  143. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/site_config.rb +76 -0
  144. data/lib/generators/vulcanize/templates/cruise/config/rubber/role/web_tools/cruise-nginx.conf +11 -0
  145. data/lib/generators/vulcanize/templates/cruise/config/rubber/rubber-cruise.yml +18 -0
  146. data/lib/generators/vulcanize/templates/cruise/templates.yml +1 -0
  147. data/lib/generators/vulcanize/templates/haproxy/config/rubber/deploy-haproxy.rb +45 -0
  148. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-base.conf +26 -0
  149. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-default.conf +8 -0
  150. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +9 -0
  151. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf +11 -0
  152. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslogd-default.conf +21 -0
  153. data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/web_tools/haproxy-nginx.conf +10 -0
  154. data/lib/generators/vulcanize/templates/haproxy/config/rubber/rubber-haproxy.yml +7 -0
  155. data/lib/generators/vulcanize/templates/haproxy/templates.yml +1 -0
  156. data/lib/generators/vulcanize/templates/jetty/config/rubber/deploy-jetty.rb +59 -0
  157. data/lib/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.sh +589 -0
  158. data/lib/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.xml +199 -0
  159. data/lib/generators/vulcanize/templates/jetty/config/rubber/role/jetty/monit-jetty.conf +9 -0
  160. data/lib/generators/vulcanize/templates/jetty/config/rubber/rubber-jetty.yml +10 -0
  161. data/lib/generators/vulcanize/templates/jetty/templates.yml +1 -0
  162. data/lib/generators/vulcanize/templates/memcached/config/memcached.yml +28 -0
  163. data/lib/generators/vulcanize/templates/memcached/config/rubber/common/memcached.yml +14 -0
  164. data/lib/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached.conf +52 -0
  165. data/lib/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached_munin_plugin +249 -0
  166. data/lib/generators/vulcanize/templates/memcached/config/rubber/rubber-memcached.yml +7 -0
  167. data/lib/generators/vulcanize/templates/memcached/templates.yml +1 -0
  168. data/lib/generators/vulcanize/templates/minimal_mysql/templates.yml +7 -0
  169. data/lib/generators/vulcanize/templates/minimal_nodb/templates.yml +6 -0
  170. data/lib/generators/vulcanize/templates/mongrel/config/rubber/deploy-mongrel.rb +75 -0
  171. data/lib/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/mongrel_cluster.yml +12 -0
  172. data/lib/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/monit-mongrel.conf +20 -0
  173. data/lib/generators/vulcanize/templates/mongrel/config/rubber/rubber-mongrel.yml +9 -0
  174. data/lib/generators/vulcanize/templates/mongrel/templates.yml +1 -0
  175. data/lib/generators/vulcanize/templates/monit/config/rubber/common/monit-default.conf +15 -0
  176. data/lib/generators/vulcanize/templates/monit/config/rubber/common/monit.conf +252 -0
  177. data/lib/generators/vulcanize/templates/monit/config/rubber/deploy-monit.rb +33 -0
  178. data/lib/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +10 -0
  179. data/lib/generators/vulcanize/templates/monit/config/rubber/rubber-monit.yml +6 -0
  180. data/lib/generators/vulcanize/templates/monit/templates.yml +1 -0
  181. data/lib/generators/vulcanize/templates/munin/config/rubber/common/monit-munin.conf +8 -0
  182. data/lib/generators/vulcanize/templates/munin/config/rubber/common/munin-node.conf +48 -0
  183. data/lib/generators/vulcanize/templates/munin/config/rubber/common/munin-plugins.conf +11 -0
  184. data/lib/generators/vulcanize/templates/munin/config/rubber/deploy-munin.rb +46 -0
  185. data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-nginx.conf +8 -0
  186. data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-plugins.conf +31 -0
  187. data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +81 -0
  188. data/lib/generators/vulcanize/templates/munin/config/rubber/rubber-munin.yml +8 -0
  189. data/lib/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +55 -0
  190. data/lib/generators/vulcanize/templates/munin/script/munin/example_simple.rb +24 -0
  191. data/lib/generators/vulcanize/templates/munin/templates.yml +1 -0
  192. data/lib/generators/vulcanize/templates/mysql/config/rubber/common/database.yml +12 -0
  193. data/lib/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +169 -0
  194. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/apparmor-mysql.conf +46 -0
  195. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/crontab +14 -0
  196. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/monit-mysql.cnf +10 -0
  197. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/my.cnf +163 -0
  198. data/lib/generators/vulcanize/templates/mysql/config/rubber/role/mysql_slave/mysql_slave_munin_plugin +51 -0
  199. data/lib/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +47 -0
  200. data/lib/generators/vulcanize/templates/mysql/templates.yml +1 -0
  201. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/common/mysql_cluster_migrations.rb +13 -0
  202. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb +177 -0
  203. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_data/my.cnf +15 -0
  204. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_mgm/ndb_mgmd.cnf +39 -0
  205. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf +10 -0
  206. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/my.cnf +23 -0
  207. data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/rubber-mysql_cluster.yml +32 -0
  208. data/lib/generators/vulcanize/templates/mysql_cluster/templates.yml +1 -0
  209. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/database.yml +16 -0
  210. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf +10 -0
  211. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +153 -0
  212. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.conf +10 -0
  213. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.lua +5 -0
  214. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb +52 -0
  215. data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/rubber-mysql_proxy.yml +11 -0
  216. data/lib/generators/vulcanize/templates/mysql_proxy/templates.yml +1 -0
  217. data/lib/generators/vulcanize/templates/nginx/config/rubber/deploy-nginx.rb +45 -0
  218. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/nginx/crontab +9 -0
  219. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/nginx/monit-nginx.conf +8 -0
  220. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/nginx/nginx.conf +42 -0
  221. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
  222. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-index.html +30 -0
  223. data/lib/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
  224. data/lib/generators/vulcanize/templates/nginx/config/rubber/rubber-nginx.yml +10 -0
  225. data/lib/generators/vulcanize/templates/nginx/templates.yml +1 -0
  226. data/lib/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +46 -0
  227. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +34 -0
  228. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +7 -0
  229. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +47 -0
  230. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf +46 -0
  231. data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +35 -0
  232. data/lib/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +15 -0
  233. data/lib/generators/vulcanize/templates/passenger/templates.yml +3 -0
  234. data/lib/generators/vulcanize/templates/postgresql/config/rubber/common/database.yml +12 -0
  235. data/lib/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +131 -0
  236. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/crontab +14 -0
  237. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/monit-postgresql.conf +10 -0
  238. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/pg_hba.conf +89 -0
  239. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql-sysctl.conf +6 -0
  240. data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +504 -0
  241. data/lib/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +45 -0
  242. data/lib/generators/vulcanize/templates/postgresql/templates.yml +1 -0
  243. data/lib/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +37 -0
  244. data/lib/generators/vulcanize/templates/redis/config/rubber/role/redis/crontab +8 -0
  245. data/lib/generators/vulcanize/templates/redis/config/rubber/role/redis/monit-redis.conf +9 -0
  246. data/lib/generators/vulcanize/templates/redis/config/rubber/role/redis/redis.conf +141 -0
  247. data/lib/generators/vulcanize/templates/redis/config/rubber/rubber-redis.yml +4 -0
  248. data/lib/generators/vulcanize/templates/redis/templates.yml +1 -0
  249. data/lib/generators/vulcanize/templates/resque/config/initializers/resque.rb +15 -0
  250. data/lib/generators/vulcanize/templates/resque/config/rubber/common/resque.yml +5 -0
  251. data/lib/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +58 -0
  252. data/lib/generators/vulcanize/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf +14 -0
  253. data/lib/generators/vulcanize/templates/resque/config/rubber/role/resque_worker/monit-resque_worker.conf +19 -0
  254. data/lib/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +18 -0
  255. data/lib/generators/vulcanize/templates/resque/script/resque_worker_management.rb +112 -0
  256. data/lib/generators/vulcanize/templates/resque/templates.rb +1 -0
  257. data/lib/generators/vulcanize/templates/resque/templates.yml +3 -0
  258. data/lib/generators/vulcanize/templates/sphinx/config/rubber/common/sphinx.yml +46 -0
  259. data/lib/generators/vulcanize/templates/sphinx/config/rubber/deploy-sphinx.rb +112 -0
  260. data/lib/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/crontab +11 -0
  261. data/lib/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf +13 -0
  262. data/lib/generators/vulcanize/templates/sphinx/config/rubber/rubber-sphinx.yml +6 -0
  263. data/lib/generators/vulcanize/templates/sphinx/templates.yml +1 -0
  264. data/lib/generators/vulcanize/vulcanize_generator.rb +157 -0
  265. data/lib/rubber/cloud/aws.rb +7 -2
  266. data/lib/rubber/dns/zerigo.rb +60 -125
  267. data/lib/rubber/environment.rb +6 -6
  268. data/lib/rubber/generator.rb +33 -25
  269. data/lib/rubber/instance.rb +11 -1
  270. data/lib/rubber/railtie.rb +14 -0
  271. data/lib/rubber/recipes/rubber/deploy.rb +3 -3
  272. data/lib/rubber/recipes/rubber/instances.rb +12 -1
  273. data/lib/rubber/recipes/rubber/setup.rb +96 -55
  274. data/lib/rubber/recipes/rubber/spot_requests.rb +6 -0
  275. data/lib/rubber/recipes/rubber/static_ips.rb +83 -0
  276. data/lib/rubber/recipes/rubber/utils.rb +39 -16
  277. data/lib/rubber/recipes/rubber/volumes.rb +4 -4
  278. data/lib/rubber/recipes/rubber.rb +16 -9
  279. data/lib/rubber/util.rb +28 -1
  280. data/lib/rubber.rb +47 -7
  281. data/rails/init.rb +1 -4
  282. data/test/environment_test.rb +3 -0
  283. data/test/generator_test.rb +47 -0
  284. data/test/instance_test.rb +3 -0
  285. data/test/test_helper.rb +6 -0
  286. data/test/util_test.rb +3 -0
  287. data/test/zerigo_test.rb +87 -0
  288. metadata +275 -50
  289. data/generators/vulcanize/templates/resque/config/rubber/deploy-resque-worker-default.rb +0 -38
  290. data/generators/vulcanize/templates/resque/config/rubber/role/resque_worker_default/monit-resque_worker_default.conf +0 -19
  291. /data/generators/vulcanize/templates/{complete_passenger_mysql → complete_passenger}/config/rubber/rubber-complete.yml +0 -0
@@ -0,0 +1,157 @@
1
+ require 'find'
2
+ require 'yaml'
3
+
4
+ if defined?(Rails) && Rails::VERSION::MAJOR == 2
5
+ require 'fileutils'
6
+ require 'commands/generate'
7
+
8
+ class VulcanizeGenerator < Rails::Generator::NamedBase
9
+
10
+ TEMPLATE_ROOT = File.dirname(__FILE__) + "/templates" unless defined?(TEMPLATE_ROOT)
11
+ TEMPLATE_FILE = "templates.yml" unless defined?(TEMPLATE_FILE)
12
+
13
+ def manifest
14
+ record do |m|
15
+ templates = [file_name] + actions
16
+ templates.each do |t|
17
+ apply_template(m, t)
18
+ end
19
+ end
20
+ end
21
+
22
+ def apply_template(m, name)
23
+ sp = source_path("#{name}/")
24
+ unless File.directory?(sp)
25
+ raise Rails::Generator::UsageError.new("Invalid template #{name}, use one of #{valid_templates.join(', ')}")
26
+ end
27
+
28
+ templ_conf = load_template_config(sp)
29
+ deps = templ_conf['dependent_templates'] || []
30
+ deps.each do |dep|
31
+ apply_template(m, dep)
32
+ end
33
+
34
+ Find.find(sp) do |f|
35
+ Find.prune if File.basename(f) =~ /^(CVS|\.svn)$/
36
+ Find.prune if f == "#{sp}#{TEMPLATE_FILE}"
37
+
38
+ rel = f.gsub(/#{source_root}\//, '')
39
+ dest_rel = rel.gsub(/^#{name}\//, '')
40
+ m.directory(dest_rel) if File.directory?(f)
41
+ if File.file?(f)
42
+ # force scripts to be executable
43
+ opts = (File.read(f) =~ /^#!/) ? {:chmod => 0755} : {}
44
+ m.file(rel, dest_rel, opts)
45
+ end
46
+
47
+ end
48
+ end
49
+
50
+ protected
51
+ def valid_templates
52
+ valid = Dir.entries(TEMPLATE_ROOT).delete_if {|e| e =~ /(^\.)|svn|CVS/ }
53
+ end
54
+
55
+ def load_template_config(template_dir)
56
+ templ_file = "#{template_dir}/templates.yml"
57
+ templ_conf = YAML.load(File.read(templ_file)) rescue {}
58
+ return templ_conf
59
+ end
60
+
61
+ def banner
62
+ usage = "Usage: #{$0} vulcanize template_name ...\n"
63
+ usage << "where template_name is one of:\n\n"
64
+ valid_templates.each do |t|
65
+ templ_conf = load_template_config("#{TEMPLATE_ROOT}/#{t}")
66
+ desc = templ_conf['description']
67
+ usage << " #{t}: #{desc}\n"
68
+ end
69
+ return usage
70
+ end
71
+ end
72
+
73
+ else
74
+ require 'rails/generators'
75
+
76
+ class VulcanizeGenerator < Rails::Generators::NamedBase
77
+
78
+ def self.source_root
79
+ File.join(File.dirname(__FILE__), 'templates')
80
+ end
81
+
82
+ def copy_template_files
83
+ @template_dependencies = find_dependencies(file_name)
84
+ ([file_name] + @template_dependencies).each do |template|
85
+ apply_template(template)
86
+ end
87
+ end
88
+
89
+ protected
90
+
91
+ # helper to test for rails for optional templates
92
+ def rails?
93
+ Rubber::Util::is_rails?
94
+ end
95
+
96
+ def find_dependencies(name)
97
+ template_dir = File.join(self.class.source_root, name, '')
98
+ unless File.directory?(template_dir)
99
+ raise Rails::Generators::Error.new("Invalid template #{name}, use one of #{valid_templates.join(', ')}")
100
+ end
101
+
102
+ template_conf = load_template_config(template_dir)
103
+ template_dependencies = template_conf['dependent_templates'] || []
104
+
105
+ template_dependencies.clone.each do |dep|
106
+ template_dependencies.concat(find_dependencies(dep))
107
+ end
108
+
109
+ return template_dependencies.uniq
110
+ end
111
+
112
+ def apply_template(name)
113
+ template_dir = File.join(self.class.source_root, name, '')
114
+ unless File.directory?(template_dir)
115
+ raise Rails::Generators::Error.new("Invalid template #{name}, use one of #{valid_templates.join(', ')}")
116
+ end
117
+
118
+ template_conf = load_template_config(template_dir)
119
+
120
+ extra_generator_steps_file = File.join(template_dir, 'templates.rb')
121
+ if File.exist? extra_generator_steps_file
122
+ eval File.read(extra_generator_steps_file), binding, extra_generator_steps_file
123
+ end
124
+
125
+ Find.find(template_dir) do |f|
126
+ Find.prune if f == File.join(template_dir, 'templates.yml') # don't copy over templates.yml
127
+ Find.prune if f == extra_generator_steps_file # don't copy over templates.rb
128
+
129
+ template_rel = f.gsub(/#{template_dir}/, '')
130
+ source_rel = f.gsub(/#{self.class.source_root}\//, '')
131
+ dest_rel = source_rel.gsub(/^#{name}\//, '')
132
+
133
+ # Only include optional files when their conditions eval to true
134
+ optional = template_conf['optional'][template_rel] rescue nil
135
+ Find.prune if optional && ! eval(optional)
136
+
137
+ if File.directory?(f)
138
+ empty_directory(dest_rel)
139
+ else
140
+ copy_file(source_rel, dest_rel)
141
+ src_mode = File.stat(f).mode
142
+ dest_mode = File.stat(File.join(destination_root, dest_rel)).mode
143
+ chmod(dest_rel, src_mode) if src_mode != dest_mode
144
+ end
145
+ end
146
+ end
147
+
148
+ def valid_templates
149
+ valid = Dir.entries(self.class.source_root).delete_if {|e| e =~ /(^\.)|svn|CVS/ }
150
+ end
151
+
152
+ def load_template_config(template_dir)
153
+ YAML.load(File.read(File.join(template_dir, 'templates.yml'))) rescue {}
154
+ end
155
+ end
156
+
157
+ end
@@ -22,7 +22,7 @@ module Rubber
22
22
  end
23
23
 
24
24
  def create_spot_instance_request(spot_price, ami, ami_type, security_groups, availability_zone)
25
- response = @ec2.create_spot_instances_request(:spot_price => spot_price, :image_id => ami, :key_name => @aws_env.key_name, :instance_type => ami_type, :security_group => security_groups, :availability_zone => availability_zone)
25
+ response = @ec2.request_spot_instances(:spot_price => spot_price, :image_id => ami, :key_name => @aws_env.key_name, :instance_type => ami_type, :security_group => security_groups, :availability_zone => availability_zone)
26
26
  request_id = response.spotInstanceRequestSet.item[0].spotInstanceRequestId
27
27
  return request_id
28
28
  end
@@ -42,6 +42,7 @@ module Rubber
42
42
  instance[:internal_host] = item.privateDnsName
43
43
  instance[:state] = item.instanceState.name
44
44
  instance[:zone] = item.placement.availabilityZone
45
+ instance[:platform] = item.platform || 'linux'
45
46
  instances << instance
46
47
  end
47
48
  end if response.reservationSet
@@ -223,7 +224,9 @@ module Rubber
223
224
  arch = case arch when /i\d86/ then "i386" else arch end
224
225
 
225
226
  capistrano.sudo_script "create_bundle", <<-CMD
227
+ rvm use system
226
228
  export RUBYLIB=/usr/lib/site_ruby/
229
+ unset RUBYOPT
227
230
  nohup ec2-bundle-vol --batch -d /mnt -k #{ec2_pk_dest} -c #{ec2_cert_dest} -u #{@aws_env.account} -p #{image_name} -r #{arch} &> /tmp/ec2-bundle-vol.log &
228
231
  echo "Creating image from instance volume..."
229
232
  while true; do
@@ -234,7 +237,9 @@ module Rubber
234
237
  CMD
235
238
 
236
239
  capistrano.sudo_script "register_bundle", <<-CMD
240
+ rvm use system
237
241
  export RUBYLIB=/usr/lib/site_ruby/
242
+ unset RUBYOPT
238
243
  echo "Uploading image to S3..."
239
244
  ec2-upload-bundle --batch -b #{@aws_env.image_bucket} -m /mnt/#{image_name}.manifest.xml -a #{@aws_env.access_key} -s #{@aws_env.secret_access_key}
240
245
  CMD
@@ -277,7 +282,7 @@ module Rubber
277
282
  end
278
283
 
279
284
  def destroy_spot_instance_request(request_id)
280
- @ec2.destroy_spot_instance_requests :spot_instance_request_id => request_id
285
+ @ec2.cancel_spot_instance_requests :spot_instance_request_id => request_id
281
286
  end
282
287
 
283
288
  def describe_load_balancers(name=nil)
@@ -1,170 +1,105 @@
1
1
  require 'rubygems'
2
- require 'httparty'
2
+ require 'zerigo_dns'
3
3
 
4
4
  module Rubber
5
5
  module Dns
6
6
 
7
+ class Zerigo < Base
7
8
 
8
- class Zone
9
- include HTTParty
10
- format :xml
11
-
12
- @@zones = {}
13
- def self.get_zone(domain, provider_env)
14
- @@zones[domain] ||= Zone.new(provider_env.customer_id, provider_env.email, provider_env.token, domain)
15
- end
9
+ def initialize(env)
10
+ super(env, "zerigo")
16
11
 
17
- def initialize(customer_id, email, token, domain)
18
- self.class.basic_auth email, token
19
- self.class.base_uri "https://ns.zerigo.com/accounts/#{customer_id}"
20
- @domain = domain
21
- refresh()
12
+ ::Zerigo::DNS::Base.user = provider_env.email
13
+ ::Zerigo::DNS::Base.password = provider_env.token
22
14
  end
23
15
 
24
- def check_status(response)
25
- code = response.code
26
- if code < 200 || code > 299
27
- msg = "Failed to access zerigo api (http_status=#{code})"
28
- msg += ", check dns_providers.zerigo.customer_id/email/token in rubber.yml" if code == 401
29
- raise msg
30
- end
31
- return response
16
+ def host_to_opts(host)
17
+ opts = {}
18
+ opts[:id] = host.id
19
+ opts[:host] = host.hostname || ''
20
+ opts[:type] = host.host_type
21
+ opts[:data] = host.data if host.data
22
+ opts[:ttl] = host.ttl if host.ttl
23
+ opts[:priority] = host.priority if host.priority
24
+ return opts
32
25
  end
33
26
 
34
- def create_host(opts)
35
- host = opts_to_host(opts, new_host())
36
- check_status self.class.post("/zones/#{@zone['id']}/hosts.xml", :body => {:host => host})
27
+ def opts_to_host(opts, host={})
28
+ host['hostname'] = opts[:host]
29
+ host['host_type'] = opts[:type]
30
+ host['data'] = opts[:data] if opts[:data]
31
+ host['ttl'] = opts[:ttl] if opts[:ttl]
32
+ host['priority'] = opts[:priority] if opts[:priority]
33
+ return host
37
34
  end
38
35
 
39
- def find_host_records(opts={})
36
+ def find_hosts(opts = {})
37
+ opts = setup_opts(opts, [:host, :domain])
40
38
  result = []
39
+ zone = ::Zerigo::DNS::Zone.find_or_create(opts[:domain])
40
+ params = { :zone_id => zone.id }
41
+
41
42
  hn = opts[:host]
42
43
  ht = opts[:type]
43
44
  hd = opts[:data]
44
45
  has_host = hn && hn != '*'
45
-
46
- url = "/zones/#{@zone['id']}/hosts.xml"
47
46
  if has_host
48
- url << "?fqdn="
47
+ url = ""
49
48
  url << "#{hn}." if hn.strip.size > 0
50
- url << "#{@domain}"
49
+ url << "#{opts[:domain]}"
50
+ params[:fqdn] = url
51
51
  end
52
- hosts = self.class.get(url)
53
-
54
- # returns 404 on not found, so don't check status
55
- hosts = check_status hosts unless has_host
56
-
57
- hosts['hosts'].each do |h|
58
- keep = true
59
- if ht && h['host_type'] != ht && ht != '*'
60
- keep = false
61
- end
62
- if hd && h['data'] != hd
63
- keep = false
64
- end
65
- result << host_to_opts(h) if keep
66
- end if hosts['hosts']
67
-
68
- return result
69
- end
70
-
71
- def update_host(host_id, opts)
72
- host = opts_to_host(opts, new_host())
73
- check_status self.class.put("/zones/#{@zone['id']}/hosts/#{host_id}.xml", :body => {:host => host})
74
- end
75
52
 
76
- def delete_host(host_id)
77
- check_status self.class.delete("/zones/#{@zone['id']}/hosts/#{host_id}.xml")
78
- end
79
-
80
- def refresh
81
- zone_id = @zone['id'] rescue nil
82
- if zone_id
83
- @zone = check_status self.class.get("/zones/#{zone_id}.xml")
84
- else
85
- zones = check_status self.class.get('/zones.xml')
86
- @zone = zones["zones"].find {|z| z["domain"] == @domain }
53
+ begin
54
+ hosts = ::Zerigo::DNS::Host.find(:all, :params=> params)
55
+
56
+ hosts.each do |h|
57
+ keep = true
58
+ if ht && h.host_type != ht && ht != '*'
59
+ keep = false
60
+ end
61
+ if hd && h.data != hd
62
+ keep = false
63
+ end
64
+ result << h if keep
65
+ end if hosts
66
+ rescue ActiveResource::ResourceNotFound => e
87
67
  end
88
- if ! @zone
89
- zone = new_zone()
90
- zone['domain'] = @domain
91
- zones = check_status self.class.post('/zones.xml', :body => {:zone => zone})
92
- @zone = zones['zone']
93
- end
94
- end
95
68
 
96
- def zone_record
97
- return @zone
98
- end
99
-
100
- private
101
-
102
- def new_host
103
- check_status(self.class.get("/zones/#{@zone['id']}/hosts/new.xml"))['host']
104
- end
105
-
106
- def new_zone
107
- check_status(self.class.get("/zones/new.xml"))['zone']
108
- end
109
-
110
- def opts_to_host(opts, host={})
111
- host['hostname'] = opts[:host]
112
- host['host_type'] = opts[:type]
113
- host['data'] = opts[:data] if opts[:data]
114
- host['ttl'] = opts[:ttl] if opts[:ttl]
115
- host['priority'] = opts[:priority] if opts[:priority]
116
- return host
117
- end
118
-
119
- def host_to_opts(host)
120
- opts = {}
121
- opts[:id] = host['id']
122
- opts[:domain] = @domain
123
- opts[:host] = host['hostname'] || ''
124
- opts[:type] = host['host_type']
125
- opts[:data] = host['data'] if host['data']
126
- opts[:ttl] = host['ttl'] if host['ttl']
127
- opts[:priority] = host['priority'] if host['priority']
128
- return opts
129
- end
130
- end
131
-
132
- class Zerigo < Base
133
-
134
- def initialize(env)
135
- super(env, "zerigo")
69
+ return result
136
70
  end
137
71
 
138
72
  def find_host_records(opts = {})
139
- opts = setup_opts(opts, [:host, :domain])
140
- zone = Zone.get_zone(opts[:domain], provider_env)
141
-
142
- zone.find_host_records(opts)
73
+ hosts = find_hosts(opts)
74
+ result = hosts.collect {|h| host_to_opts(h).merge(:domain => opts[:domain]) }
75
+ return result
143
76
  end
144
77
 
145
78
  def create_host_record(opts = {})
146
79
  opts = setup_opts(opts, [:host, :data, :domain, :type, :ttl])
147
- zone = Zone.get_zone(opts[:domain], provider_env)
148
-
149
- zone.create_host(opts)
80
+ zone = ::Zerigo::DNS::Zone.find_or_create(opts[:domain])
81
+ ::Zerigo::DNS::Host.create(opts_to_host(opts).merge(:zone_id => zone.id))
150
82
  end
151
83
 
152
84
  def destroy_host_record(opts = {})
153
85
  opts = setup_opts(opts, [:host, :domain])
154
- zone = Zone.get_zone(opts[:domain], provider_env)
86
+ zone = ::Zerigo::DNS::Zone.find_or_create(opts[:domain])
155
87
 
156
- find_host_records(opts).each do |h|
157
- zone.delete_host(h[:id])
88
+ find_hosts(opts).each do |h|
89
+ h.destroy || raise("Failed to destroy #{h.hostname}")
158
90
  end
159
91
  end
160
92
 
161
93
  def update_host_record(old_opts={}, new_opts={})
162
94
  old_opts = setup_opts(old_opts, [:host, :domain])
163
- new_opts = setup_opts(new_opts.merge(:no_defaults =>true), [])
164
- zone = Zone.get_zone(old_opts[:domain], provider_env)
95
+ new_opts = setup_opts(new_opts, [:host, :domain, :type, :data])
96
+ zone = ::Zerigo::DNS::Zone.find_or_create(old_opts[:domain])
165
97
 
166
- find_host_records(old_opts).each do |h|
167
- zone.update_host(h[:id], h.merge(new_opts))
98
+ find_hosts(old_opts).each do |h|
99
+ opts_to_host(new_opts).each do |k, v|
100
+ h.send("#{k}=", v)
101
+ end
102
+ h.save || raise("Failed to update host #{h.hostname}, #{h.errors.full_messages.join(', ')}")
168
103
  end
169
104
  end
170
105
 
@@ -22,7 +22,7 @@ module Rubber
22
22
  end
23
23
 
24
24
  def read_config(file)
25
- LOGGER.debug{"Reading rubber configuration from #{file}"}
25
+ Rubber.logger.debug{"Reading rubber configuration from #{file}"}
26
26
  if File.exist?(file)
27
27
  @items = Environment.combine(@items, YAML.load_file(file) || {})
28
28
  end
@@ -145,14 +145,14 @@ module Rubber
145
145
  global = global.clone()
146
146
  role_overrides = global.delete("roles") || {}
147
147
  host_overrides = global.delete("hosts") || {}
148
- roles.to_a.each do |role|
149
- role_overrides[role].each do |k, v|
148
+ Array(roles).each do |role|
149
+ Array(role_overrides[role]).each do |k, v|
150
150
  global[k] = Environment.combine(global[k], v)
151
- end if role_overrides[role]
151
+ end
152
152
  end
153
- host_overrides[host].each do |k, v|
153
+ Array(host_overrides[host]).each do |k, v|
154
154
  global[k] = Environment.combine(global[k], v)
155
- end if host_overrides[host]
155
+ end
156
156
  return global
157
157
  end
158
158
 
@@ -33,13 +33,13 @@ module Rubber
33
33
  Dir[dir].sort.each do |f|
34
34
  next if f =~ /\/(CVS|\.svn)\//
35
35
  if File.file?(f) && (! pat || pat.match(f))
36
- LOGGER.info{"Transforming #{f}"}
36
+ Rubber.logger.info{"Transforming #{f}"}
37
37
  begin
38
38
  transform(IO.read(f), @options)
39
39
  rescue Exception => e
40
40
  lines = e.backtrace.grep(/^\(erb\):([0-9]+)/) {|b| Regexp.last_match(1) }
41
- LOGGER.error{"Transformation failed for #{f}#{':' + lines.first if lines.first}"}
42
- LOGGER.error e.message
41
+ Rubber.logger.error{"Transformation failed for #{f}#{':' + lines.first if lines.first}"}
42
+ Rubber.logger.error e.message
43
43
  exit 1
44
44
  end
45
45
  end
@@ -113,7 +113,7 @@ module Rubber
113
113
  FileUtils.mkdir_p(File.dirname(config_path)) if config_path
114
114
 
115
115
  # Write a backup of original
116
- open("#{config_path}.bak", 'w') { |f| f.write(orig) } if config_path
116
+ open("#{config_path}.bak", 'w') { |f| f.write(orig) } if config_path && config.backup
117
117
 
118
118
  # Write out transformed file
119
119
  writer = config_path || "|#{config.write_cmd}"
@@ -130,21 +130,23 @@ module Rubber
130
130
 
131
131
  # Run post transform command if needed
132
132
  if config.post
133
- if orig == result
134
- LOGGER.info("Nothing to do, not running post command")
133
+ if fake_root
134
+ Rubber.logger.info("Not running post command as a fake root was given: #{config.post}")
135
135
  elsif no_post
136
- LOGGER.info("Not running post command as no post specified")
137
- elsif fake_root
138
- LOGGER.info("Not running post command as a fake root was given: #{config.post}")
136
+ Rubber.logger.info("Not running post command as no post specified")
139
137
  else
140
- # this lets us abort a script if a command in the middle of it errors out
141
- # stop_on_error_cmd = "function error_exit { exit 99; }; trap error_exit ERR"
142
- config.post = "#{stop_on_error_cmd}\n#{config.post}" if stop_on_error_cmd
143
-
144
- LOGGER.info{"Transformation executing post config command: #{config.post}"}
145
- LOGGER.info `#{config.post}`
146
- if $?.exitstatus != 0
147
- raise "Post command failed execution: #{config.post}"
138
+ if orig != result || force
139
+ # this lets us abort a script if a command in the middle of it errors out
140
+ # stop_on_error_cmd = "function error_exit { exit 99; }; trap error_exit ERR"
141
+ config.post = "#{stop_on_error_cmd}\n#{config.post}" if stop_on_error_cmd
142
+
143
+ Rubber.logger.info{"Transformation executing post config command: #{config.post}"}
144
+ Rubber.logger.info `#{config.post}`
145
+ if $?.exitstatus != 0
146
+ raise "Post command failed execution: #{config.post}"
147
+ end
148
+ else
149
+ Rubber.logger.info("Nothing to do, not running post command")
148
150
  end
149
151
  end
150
152
  end
@@ -174,22 +176,28 @@ module Rubber
174
176
  attr_accessor :additive
175
177
  # Lets one dynamically determine if a given file gets skipped during transformation
176
178
  attr_accessor :skip
179
+ # Backup file when transforming, defaults to true, set to false to prevent backup
180
+ attr_accessor :backup
177
181
  # use sudo to write the output file
178
182
  # attr_accessor :sudo
179
183
  # options passed in through code
180
184
  attr_accessor :options
181
185
 
186
+ def initialize
187
+ @backup = true
188
+ end
189
+
182
190
  def get_binding
183
191
  binding
184
- end
192
+ end
185
193
 
186
- def rubber_env()
187
- Rubber::Configuration.rubber_env
188
- end
189
-
190
- def rubber_instances()
191
- Rubber::Configuration.rubber_instances
192
- end
194
+ def rubber_env()
195
+ Rubber::Configuration.rubber_env
196
+ end
197
+
198
+ def rubber_instances()
199
+ Rubber::Configuration.rubber_instances
200
+ end
193
201
 
194
202
  end
195
203
 
@@ -10,7 +10,7 @@ module Rubber
10
10
  include Enumerable
11
11
 
12
12
  def initialize(file)
13
- LOGGER.debug{"Reading rubber instances from #{file}"}
13
+ Rubber.logger.debug{"Reading rubber instances from #{file}"}
14
14
  @file = file
15
15
  @items = {}
16
16
  @artifacts = {'volumes' => {}, 'static_ips' => {}}
@@ -82,6 +82,7 @@ module Rubber
82
82
  attr_accessor :internal_host, :internal_ip
83
83
  attr_accessor :static_ip, :volumes, :partitions
84
84
  attr_accessor :spot_instance_request_id
85
+ attr_accessor :platform
85
86
 
86
87
  def initialize(name, domain, roles, instance_id, security_group_list=[])
87
88
  @name = name
@@ -98,6 +99,15 @@ module Rubber
98
99
  def role_names()
99
100
  roles.collect {|r| r.name}
100
101
  end
102
+
103
+ def platform
104
+ # Deal with old instance configurations that don't have a platform value persisted.
105
+ @platform || 'linux'
106
+ end
107
+
108
+ def windows?
109
+ platform == 'windows'
110
+ end
101
111
  end
102
112
 
103
113
  # The configuration for a single role contained in the list
@@ -0,0 +1,14 @@
1
+ require 'rubber'
2
+ require 'rails'
3
+
4
+ module Rubber
5
+
6
+ class Railtie < Rails::Railtie
7
+
8
+ initializer "rubber.configure_rails_initialization" do
9
+ Rubber::initialize(Rails.root, Rails.env)
10
+ end
11
+
12
+ end
13
+
14
+ end
@@ -59,8 +59,8 @@ namespace :rubber do
59
59
  Sets permissions of files in application directory to be owned by app_user.
60
60
  DESC
61
61
  task :setup_app_permissions do
62
- run "find #{shared_path} -name cached-copy -prune -o -print | xargs chown #{rubber_env.app_user}:#{rubber_env.app_user}"
63
- run "chown -R #{rubber_env.app_user}:#{rubber_env.app_user} #{current_path}/tmp"
62
+ rsudo "find #{shared_path} -name cached-copy -prune -o -print | xargs chown #{rubber_env.app_user}:#{rubber_env.app_user}"
63
+ rsudo "chown -R #{rubber_env.app_user}:#{rubber_env.app_user} #{current_path}/tmp"
64
64
  end
65
65
 
66
66
  def run_config(options={})
@@ -84,7 +84,7 @@ namespace :rubber do
84
84
  put(File.read(secret), File.join(path, base, File.basename(secret)), :mode => "+r")
85
85
  end
86
86
 
87
- sudo "sh -c 'cd #{path} && #{extra_env} rake rubber:config'"
87
+ rsudo "cd #{path} && #{extra_env} rake rubber:config"
88
88
  end
89
89
 
90
90
  end
@@ -225,8 +225,12 @@ namespace :rubber do
225
225
  instance_item.external_ip = instance[:external_ip]
226
226
  instance_item.internal_host = instance[:internal_host]
227
227
  instance_item.zone = instance[:zone]
228
+ instance_item.platform = instance[:platform]
228
229
  rubber_instances.save()
229
230
 
231
+ # turn back on root ssh access if we are using root as the capistrano user for connecting
232
+ enable_root_ssh(instance_item.external_ip, fetch(:initial_ssh_user, 'ubuntu')) if user == 'root'
233
+
230
234
  # setup amazon elastic ips if configured to do so
231
235
  setup_static_ips
232
236
 
@@ -241,7 +245,14 @@ namespace :rubber do
241
245
  # so that we can update all aliases
242
246
 
243
247
  task :_get_ip, :hosts => instance_item.external_ip do
244
- instance_item.internal_ip = capture(print_ip_command).strip
248
+ # There's no good way to get the internal IP for a Windows host, so just set it to the external
249
+ # and let the router handle mapping to the internal network.
250
+ if instance_item.windows?
251
+ instance_item.internal_ip = instance_item.external_ip
252
+ else
253
+ instance_item.internal_ip = capture(print_ip_command).strip
254
+ end
255
+
245
256
  rubber_instances.save()
246
257
  end
247
258