gigpark-ec2onrails 0.9.10.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. data/CHANGELOG +190 -0
  2. data/COPYING +339 -0
  3. data/Manifest +160 -0
  4. data/README.textile +233 -0
  5. data/Rakefile +31 -0
  6. data/TODO +104 -0
  7. data/ec2onrails.gemspec +46 -0
  8. data/echoe_config.rb +27 -0
  9. data/examples/Capfile +3 -0
  10. data/examples/deploy.rb +103 -0
  11. data/examples/s3.yml +9 -0
  12. data/lib/ec2onrails.rb +20 -0
  13. data/lib/ec2onrails/capistrano_utils.rb +47 -0
  14. data/lib/ec2onrails/recipes.rb +146 -0
  15. data/lib/ec2onrails/recipes/db.rb +366 -0
  16. data/lib/ec2onrails/recipes/deploy.rb +26 -0
  17. data/lib/ec2onrails/recipes/server.rb +517 -0
  18. data/lib/ec2onrails/version.rb +29 -0
  19. data/server/build +74 -0
  20. data/server/files/etc/README +7 -0
  21. data/server/files/etc/aliases +5 -0
  22. data/server/files/etc/cron.d/ec2onrails +16 -0
  23. data/server/files/etc/cron.daily/app +31 -0
  24. data/server/files/etc/cron.daily/logrotate_post +25 -0
  25. data/server/files/etc/cron.hourly/app +31 -0
  26. data/server/files/etc/cron.monthly/app +31 -0
  27. data/server/files/etc/cron.weekly/app +31 -0
  28. data/server/files/etc/default/varnish +33 -0
  29. data/server/files/etc/default/varnishncsa +11 -0
  30. data/server/files/etc/denyhosts.conf +628 -0
  31. data/server/files/etc/dpkg/dpkg.cfg +13 -0
  32. data/server/files/etc/ec2onrails/rails_env +1 -0
  33. data/server/files/etc/ec2onrails/roles.yml +5 -0
  34. data/server/files/etc/environment +2 -0
  35. data/server/files/etc/event.d/god +8 -0
  36. data/server/files/etc/god/db_primary.god +16 -0
  37. data/server/files/etc/god/dkim_filter.god +17 -0
  38. data/server/files/etc/god/master.conf +40 -0
  39. data/server/files/etc/god/memcache.god +15 -0
  40. data/server/files/etc/god/notifications.god +11 -0
  41. data/server/files/etc/god/proxy.god +40 -0
  42. data/server/files/etc/god/system.god +37 -0
  43. data/server/files/etc/god/web.god +23 -0
  44. data/server/files/etc/init.d/ec2-every-startup +29 -0
  45. data/server/files/etc/init.d/ec2-first-startup +37 -0
  46. data/server/files/etc/init.d/nginx +78 -0
  47. data/server/files/etc/logrotate.d/nginx +10 -0
  48. data/server/files/etc/logrotate.d/rails +8 -0
  49. data/server/files/etc/logrotate.d/varnish +14 -0
  50. data/server/files/etc/memcached.conf +47 -0
  51. data/server/files/etc/motd.tail +13 -0
  52. data/server/files/etc/mysql/my.cnf +152 -0
  53. data/server/files/etc/nginx/conf.d/custom.conf +1 -0
  54. data/server/files/etc/nginx/nginx.conf.erb +152 -0
  55. data/server/files/etc/postfix/main.cf +4 -0
  56. data/server/files/etc/ssh/sshd_config +96 -0
  57. data/server/files/etc/sudoers +31 -0
  58. data/server/files/etc/syslog.conf +63 -0
  59. data/server/files/etc/varnish/default.vcl.erb +140 -0
  60. data/server/files/usr/local/ec2onrails/COPYING +339 -0
  61. data/server/files/usr/local/ec2onrails/bin/archive_file +44 -0
  62. data/server/files/usr/local/ec2onrails/bin/backup_app_db +160 -0
  63. data/server/files/usr/local/ec2onrails/bin/backup_dir +89 -0
  64. data/server/files/usr/local/ec2onrails/bin/ec2_meta_data +80 -0
  65. data/server/files/usr/local/ec2onrails/bin/exec_runner +76 -0
  66. data/server/files/usr/local/ec2onrails/bin/in_role +33 -0
  67. data/server/files/usr/local/ec2onrails/bin/init_services +43 -0
  68. data/server/files/usr/local/ec2onrails/bin/install_system_files +56 -0
  69. data/server/files/usr/local/ec2onrails/bin/optimize_mysql +346 -0
  70. data/server/files/usr/local/ec2onrails/bin/public-hostname +24 -0
  71. data/server/files/usr/local/ec2onrails/bin/rails_env +33 -0
  72. data/server/files/usr/local/ec2onrails/bin/rebundle +62 -0
  73. data/server/files/usr/local/ec2onrails/bin/restore_app_db +58 -0
  74. data/server/files/usr/local/ec2onrails/bin/set_rails_env +36 -0
  75. data/server/files/usr/local/ec2onrails/bin/set_roles +36 -0
  76. data/server/files/usr/local/ec2onrails/bin/uninstall_system_files +34 -0
  77. data/server/files/usr/local/ec2onrails/config +30 -0
  78. data/server/files/usr/local/ec2onrails/lib/aws_helper.rb +75 -0
  79. data/server/files/usr/local/ec2onrails/lib/god_helper.rb +84 -0
  80. data/server/files/usr/local/ec2onrails/lib/mysql_helper.rb +100 -0
  81. data/server/files/usr/local/ec2onrails/lib/roles_helper.rb +156 -0
  82. data/server/files/usr/local/ec2onrails/lib/s3_helper.rb +116 -0
  83. data/server/files/usr/local/ec2onrails/lib/system_files_helper.rb +110 -0
  84. data/server/files/usr/local/ec2onrails/lib/system_files_manifest.rb +107 -0
  85. data/server/files/usr/local/ec2onrails/lib/utils.rb +26 -0
  86. data/server/files/usr/local/ec2onrails/lib/vendor/ini.rb +268 -0
  87. data/server/files/usr/local/ec2onrails/startup-scripts/every-startup/README +5 -0
  88. data/server/files/usr/local/ec2onrails/startup-scripts/every-startup/create-mysqld-pid-dir +26 -0
  89. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/README +5 -0
  90. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/create-dirs +45 -0
  91. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/generate-default-web-cert-and-key +49 -0
  92. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/get-hostname +27 -0
  93. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/misc +27 -0
  94. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir +24 -0
  95. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-credentials +32 -0
  96. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-file-permissions +30 -0
  97. data/server/rakefile-wrapper +26 -0
  98. data/server/rakefile.rb +267 -0
  99. data/test/autobench.conf +60 -0
  100. data/test/spec/lib/s3_helper_spec.rb +154 -0
  101. data/test/spec/lib/s3_old.yml +3 -0
  102. data/test/spec/lib/system_files_manifest_spec.rb +122 -0
  103. data/test/spec/test_files/system_files1/_manifest +13 -0
  104. data/test/spec/test_files/system_files1/test1 +0 -0
  105. data/test/spec/test_files/system_files1/test2 +0 -0
  106. data/test/spec/test_files/system_files1/testfolder/test3 +0 -0
  107. data/test/spec/test_files/system_files2/_manifest +2 -0
  108. data/test/spec/test_files/system_files2/test1 +0 -0
  109. data/test/spec/test_files/system_files2/test2 +0 -0
  110. data/test/spec/test_files/system_files2/testfolder/test3 +0 -0
  111. data/test/spec/test_files/test2 +0 -0
  112. data/test/test_app/Capfile +3 -0
  113. data/test/test_app/README +243 -0
  114. data/test/test_app/Rakefile +10 -0
  115. data/test/test_app/app/controllers/application_controller.rb +10 -0
  116. data/test/test_app/app/controllers/db_fast_controller.rb +6 -0
  117. data/test/test_app/app/controllers/fast_controller.rb +5 -0
  118. data/test/test_app/app/controllers/slow_controller.rb +6 -0
  119. data/test/test_app/app/controllers/very_slow_controller.rb +6 -0
  120. data/test/test_app/app/helpers/application_helper.rb +3 -0
  121. data/test/test_app/config/boot.rb +110 -0
  122. data/test/test_app/config/database.yml +24 -0
  123. data/test/test_app/config/deploy.rb +22 -0
  124. data/test/test_app/config/ec2onrails/config.rb +5 -0
  125. data/test/test_app/config/environment.rb +41 -0
  126. data/test/test_app/config/environments/development.rb +17 -0
  127. data/test/test_app/config/environments/production.rb +28 -0
  128. data/test/test_app/config/environments/test.rb +28 -0
  129. data/test/test_app/config/initializers/backtrace_silencers.rb +7 -0
  130. data/test/test_app/config/initializers/inflections.rb +10 -0
  131. data/test/test_app/config/initializers/mime_types.rb +5 -0
  132. data/test/test_app/config/initializers/new_rails_defaults.rb +19 -0
  133. data/test/test_app/config/initializers/session_store.rb +15 -0
  134. data/test/test_app/config/locales/en.yml +5 -0
  135. data/test/test_app/config/routes.rb +43 -0
  136. data/test/test_app/doc/README_FOR_APP +2 -0
  137. data/test/test_app/public/404.html +30 -0
  138. data/test/test_app/public/422.html +30 -0
  139. data/test/test_app/public/500.html +30 -0
  140. data/test/test_app/public/favicon.ico +0 -0
  141. data/test/test_app/public/images/rails.png +0 -0
  142. data/test/test_app/public/index.html +275 -0
  143. data/test/test_app/public/javascripts/application.js +2 -0
  144. data/test/test_app/public/javascripts/controls.js +963 -0
  145. data/test/test_app/public/javascripts/dragdrop.js +973 -0
  146. data/test/test_app/public/javascripts/effects.js +1128 -0
  147. data/test/test_app/public/javascripts/prototype.js +4320 -0
  148. data/test/test_app/public/robots.txt +5 -0
  149. data/test/test_app/script/about +4 -0
  150. data/test/test_app/script/console +3 -0
  151. data/test/test_app/script/dbconsole +3 -0
  152. data/test/test_app/script/destroy +3 -0
  153. data/test/test_app/script/generate +3 -0
  154. data/test/test_app/script/performance/benchmarker +3 -0
  155. data/test/test_app/script/performance/profiler +3 -0
  156. data/test/test_app/script/plugin +3 -0
  157. data/test/test_app/script/runner +3 -0
  158. data/test/test_app/script/server +3 -0
  159. data/test/test_app/test/performance/browsing_test.rb +9 -0
  160. data/test/test_app/test/test_helper.rb +38 -0
  161. metadata +266 -0
data/Manifest ADDED
@@ -0,0 +1,160 @@
1
+ CHANGELOG
2
+ COPYING
3
+ ec2onrails.gemspec
4
+ echoe_config.rb
5
+ examples/Capfile
6
+ examples/deploy.rb
7
+ examples/s3.yml
8
+ lib/ec2onrails/capistrano_utils.rb
9
+ lib/ec2onrails/recipes/db.rb
10
+ lib/ec2onrails/recipes/deploy.rb
11
+ lib/ec2onrails/recipes/server.rb
12
+ lib/ec2onrails/recipes.rb
13
+ lib/ec2onrails/version.rb
14
+ lib/ec2onrails.rb
15
+ Manifest
16
+ Rakefile
17
+ README.textile
18
+ server/build
19
+ server/files/etc/aliases
20
+ server/files/etc/cron.d/ec2onrails
21
+ server/files/etc/cron.daily/app
22
+ server/files/etc/cron.daily/logrotate_post
23
+ server/files/etc/cron.hourly/app
24
+ server/files/etc/cron.monthly/app
25
+ server/files/etc/cron.weekly/app
26
+ server/files/etc/default/varnish
27
+ server/files/etc/default/varnishncsa
28
+ server/files/etc/denyhosts.conf
29
+ server/files/etc/dpkg/dpkg.cfg
30
+ server/files/etc/ec2onrails/rails_env
31
+ server/files/etc/ec2onrails/roles.yml
32
+ server/files/etc/environment
33
+ server/files/etc/event.d/god
34
+ server/files/etc/god/db_primary.god
35
+ server/files/etc/god/dkim_filter.god
36
+ server/files/etc/god/master.conf
37
+ server/files/etc/god/memcache.god
38
+ server/files/etc/god/notifications.god
39
+ server/files/etc/god/proxy.god
40
+ server/files/etc/god/system.god
41
+ server/files/etc/god/web.god
42
+ server/files/etc/init.d/ec2-every-startup
43
+ server/files/etc/init.d/ec2-first-startup
44
+ server/files/etc/init.d/nginx
45
+ server/files/etc/logrotate.d/nginx
46
+ server/files/etc/logrotate.d/rails
47
+ server/files/etc/logrotate.d/varnish
48
+ server/files/etc/memcached.conf
49
+ server/files/etc/motd.tail
50
+ server/files/etc/mysql/my.cnf
51
+ server/files/etc/nginx/conf.d/custom.conf
52
+ server/files/etc/nginx/nginx.conf.erb
53
+ server/files/etc/postfix/main.cf
54
+ server/files/etc/README
55
+ server/files/etc/ssh/sshd_config
56
+ server/files/etc/sudoers
57
+ server/files/etc/syslog.conf
58
+ server/files/etc/varnish/default.vcl.erb
59
+ server/files/usr/local/ec2onrails/bin/archive_file
60
+ server/files/usr/local/ec2onrails/bin/backup_app_db
61
+ server/files/usr/local/ec2onrails/bin/backup_dir
62
+ server/files/usr/local/ec2onrails/bin/ec2_meta_data
63
+ server/files/usr/local/ec2onrails/bin/exec_runner
64
+ server/files/usr/local/ec2onrails/bin/in_role
65
+ server/files/usr/local/ec2onrails/bin/init_services
66
+ server/files/usr/local/ec2onrails/bin/install_system_files
67
+ server/files/usr/local/ec2onrails/bin/optimize_mysql
68
+ server/files/usr/local/ec2onrails/bin/public-hostname
69
+ server/files/usr/local/ec2onrails/bin/rails_env
70
+ server/files/usr/local/ec2onrails/bin/rebundle
71
+ server/files/usr/local/ec2onrails/bin/restore_app_db
72
+ server/files/usr/local/ec2onrails/bin/set_rails_env
73
+ server/files/usr/local/ec2onrails/bin/set_roles
74
+ server/files/usr/local/ec2onrails/bin/uninstall_system_files
75
+ server/files/usr/local/ec2onrails/config
76
+ server/files/usr/local/ec2onrails/COPYING
77
+ server/files/usr/local/ec2onrails/lib/aws_helper.rb
78
+ server/files/usr/local/ec2onrails/lib/god_helper.rb
79
+ server/files/usr/local/ec2onrails/lib/mysql_helper.rb
80
+ server/files/usr/local/ec2onrails/lib/roles_helper.rb
81
+ server/files/usr/local/ec2onrails/lib/s3_helper.rb
82
+ server/files/usr/local/ec2onrails/lib/system_files_helper.rb
83
+ server/files/usr/local/ec2onrails/lib/system_files_manifest.rb
84
+ server/files/usr/local/ec2onrails/lib/utils.rb
85
+ server/files/usr/local/ec2onrails/lib/vendor/ini.rb
86
+ server/files/usr/local/ec2onrails/startup-scripts/every-startup/create-mysqld-pid-dir
87
+ server/files/usr/local/ec2onrails/startup-scripts/every-startup/README
88
+ server/files/usr/local/ec2onrails/startup-scripts/first-startup/create-dirs
89
+ server/files/usr/local/ec2onrails/startup-scripts/first-startup/generate-default-web-cert-and-key
90
+ server/files/usr/local/ec2onrails/startup-scripts/first-startup/get-hostname
91
+ server/files/usr/local/ec2onrails/startup-scripts/first-startup/misc
92
+ server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir
93
+ server/files/usr/local/ec2onrails/startup-scripts/first-startup/README
94
+ server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-credentials
95
+ server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-file-permissions
96
+ server/rakefile-wrapper
97
+ server/rakefile.rb
98
+ test/autobench.conf
99
+ test/spec/lib/s3_helper_spec.rb
100
+ test/spec/lib/s3_old.yml
101
+ test/spec/lib/system_files_manifest_spec.rb
102
+ test/spec/test_files/system_files1/_manifest
103
+ test/spec/test_files/system_files1/test1
104
+ test/spec/test_files/system_files1/test2
105
+ test/spec/test_files/system_files1/testfolder/test3
106
+ test/spec/test_files/system_files2/_manifest
107
+ test/spec/test_files/system_files2/test1
108
+ test/spec/test_files/system_files2/test2
109
+ test/spec/test_files/system_files2/testfolder/test3
110
+ test/spec/test_files/test2
111
+ test/test_app/app/controllers/application_controller.rb
112
+ test/test_app/app/controllers/db_fast_controller.rb
113
+ test/test_app/app/controllers/fast_controller.rb
114
+ test/test_app/app/controllers/slow_controller.rb
115
+ test/test_app/app/controllers/very_slow_controller.rb
116
+ test/test_app/app/helpers/application_helper.rb
117
+ test/test_app/Capfile
118
+ test/test_app/config/boot.rb
119
+ test/test_app/config/database.yml
120
+ test/test_app/config/deploy.rb
121
+ test/test_app/config/ec2onrails/config.rb
122
+ test/test_app/config/environment.rb
123
+ test/test_app/config/environments/development.rb
124
+ test/test_app/config/environments/production.rb
125
+ test/test_app/config/environments/test.rb
126
+ test/test_app/config/initializers/backtrace_silencers.rb
127
+ test/test_app/config/initializers/inflections.rb
128
+ test/test_app/config/initializers/mime_types.rb
129
+ test/test_app/config/initializers/new_rails_defaults.rb
130
+ test/test_app/config/initializers/session_store.rb
131
+ test/test_app/config/locales/en.yml
132
+ test/test_app/config/routes.rb
133
+ test/test_app/doc/README_FOR_APP
134
+ test/test_app/public/404.html
135
+ test/test_app/public/422.html
136
+ test/test_app/public/500.html
137
+ test/test_app/public/favicon.ico
138
+ test/test_app/public/images/rails.png
139
+ test/test_app/public/index.html
140
+ test/test_app/public/javascripts/application.js
141
+ test/test_app/public/javascripts/controls.js
142
+ test/test_app/public/javascripts/dragdrop.js
143
+ test/test_app/public/javascripts/effects.js
144
+ test/test_app/public/javascripts/prototype.js
145
+ test/test_app/public/robots.txt
146
+ test/test_app/Rakefile
147
+ test/test_app/README
148
+ test/test_app/script/about
149
+ test/test_app/script/console
150
+ test/test_app/script/dbconsole
151
+ test/test_app/script/destroy
152
+ test/test_app/script/generate
153
+ test/test_app/script/performance/benchmarker
154
+ test/test_app/script/performance/profiler
155
+ test/test_app/script/plugin
156
+ test/test_app/script/runner
157
+ test/test_app/script/server
158
+ test/test_app/test/performance/browsing_test.rb
159
+ test/test_app/test/test_helper.rb
160
+ TODO
data/README.textile ADDED
@@ -0,0 +1,233 @@
1
+ h1. EC2 on Rails
2
+
3
+ h2. Deploy a Ruby on Rails app on EC2 in five minutes
4
+
5
+ Main Page: "http://ec2onrails.rubyforge.org":http://ec2onrails.rubyforge.org
6
+
7
+ Code on Github: "http://github.com/pauldowman/ec2onrails":http://github.com/pauldowman/ec2onrails
8
+
9
+ EC2 on Rails is an Ubuntu Linux server image for "Amazon's EC2 hosting service":http://www.amazon.com/b/ref=sc_fe_l_2/102-6342260-7987311?ie=UTF8&node=201590011&no=3435361 that's ready to run a standard Ruby on Rails application with little or no customization. It's a Ruby on Rails "virtual appliance":http://en.wikipedia.org/wiki/Virtual_appliance.
10
+
11
+ If you have an EC2 account and can start EC2 instances you're five minutes away from deploying your Rails app.
12
+
13
+ EC2 on Rails is "opinionated software":http://gettingreal.37signals.com/ch04_Make_Opinionated_Software.php: the opinion is that for many rails apps the server setup can be generalized and shared the same way as the web application framework itself. For many people (Twitter, this isn't for you) the server image can be treated the same way as other shared libraries. And if the day comes when your needs areunique enough that EC2 on Rails can't be configured to work for you then you can bundle your own image from it or fork the build source and customize it.
14
+
15
+ But until then, why spend your time configuring servers?
16
+
17
+ Features of the EC2 image:
18
+
19
+ * Ready to deploy a Rails app with little or no configuration of the server required
20
+ * Optional Amazon Elastic Block Store (EBS) setup and support for MySQL database persistence.
21
+ * Automatic backup of MySQL database to S3 (EBS enabled: snapshots taken every 2 hrs; Non-EBS enabled: full backup nightly + incremental backup using binary logs every 5 minutes if not using )
22
+ * Capistrano tasks to customize the server image, archive and restore the database to/from S3, and more (available as a rubygem)
23
+ * Mongrel_cluster behind Apache 2.2, configured according to
24
+ "Coda Hale's excellent guide":http://blog.codahale.com/2006/06/19/time-for-a-grown-up-server-rails-mongrel-apache-capistrano-and-you/
25
+ * Ruby on Rails 2.1.0, 2.0.2 and 1.2.6
26
+ * Ruby 1.8.6
27
+ * MySQL 5
28
+ * "memcached":http://www.danga.com/memcached/
29
+ * "god":http://god.rubyforge.org/ configured to monitor apache or nginx, mongrel, mysql, memcached, drive space and system load
30
+ * Ubuntu 8.04 LTS "Hardy" base image built using "Eric Hammond's EC2 Ubuntu script":http://alestic.com/
31
+ * SSL support
32
+ * Amazon AMI tools installed
33
+ * Apache or Nginx web proxies
34
+ * MySQL, Apache/Nginx, and syslog configured to use /mnt for data and logging so you don't fill up EC2's small root filesystem
35
+ * Automatically archives Rails and Apache logs to S3 nightly.
36
+ * 32-bit and 64-bit images available (supports all instance types, small to extra large).
37
+ * Created using a build file, full source is "available":http://rubyforge.org/scm/?group_id=4552 (the EC2 on Rails script is run from "Eric Hammond's EC2 Ubuntu script":http://alestic.com/)
38
+ * Can be used as a clustered Rails app running on multiple instances
39
+ * Automatically runs hourly, daily, weekly and monthly scripts if they exist in Rails application's script directory
40
+ * Local "Postfix":http://www.postfix.org/ SMTP mail server (only available from within the instance, not listening on external network interfaces)
41
+
42
+
43
+ h2. Using the image
44
+
45
+ This documentation will be improved soon, for now hopefully this covers the basics.
46
+
47
+ The current AMI id's are:
48
+ * ami-c9bc58a0 (32-bit)
49
+ * ami-cbbc58a2 (64-bit)
50
+
51
+ _I will keep these images available for as long as possible, they will not be deleted for at least a few years._
52
+
53
+
54
+ h4. 1. Install the gem
55
+
56
+ <pre>sudo gem install ec2onrails</pre>
57
+
58
+ h4. 2. Add the config files to your Rails app
59
+
60
+ You will need to place "Capfile":http://github.com/pauldowman/ec2onrails/raw/master/examples/Capfile in the root of your rails folder, and put "deploy.rb":http://github.com/pauldowman/ec2onrails/raw/master/examples/deploy.rb and "s3.yml":http://github.com/pauldowman/ec2onrails/raw/master/examples/s3.yml in the config folder.
61
+
62
+ Within your rails directory, run
63
+ <pre>
64
+ wget -q -O Capfile http://github.com/pauldowman/ec2onrails/raw/master/examples/Capfile
65
+ wget -q -O config/deploy.rb http://github.com/pauldowman/ec2onrails/raw/master/examples/deploy.rb
66
+ wget -q -O config/s3.yml http://github.com/pauldowman/ec2onrails/raw/master/examples/s3.yml
67
+ </pre>
68
+
69
+
70
+ _Be sure to customize those files and read the comments._
71
+
72
+ In your database.yml file, add <code>host: db_primary</code> to the host of other database configuration options. After running "cap ec2onrails:server:set_roles" it will resolve to the instance defined in your Capistrano "db" role.
73
+
74
+ h4. 3. Start up one or more instances of the image.
75
+
76
+ There is nothing EC2 on Rails-specific here yet (though soon there will be a Capistrano task to do this for you), if you've started EC2 instances before you can skip this section. Otherwise, I'm not going to lie, this part is complicated and will take a lot more than 5 minutes the first time.
77
+
78
+ Read the "running an instance section":http://docs.amazonwebservices.com/AWSEC2/2007-08-29/GettingStartedGuide/running-an-instance.html in Amazon's getting started guide.
79
+
80
+ For the AMI id's of the current images do <code>cap ec2onrails:ami_ids</code> from within the app that you configured in the previous step (they're also listed earlier on this page).
81
+
82
+ _NOTE: Only use the images that match the current version of the gem._
83
+
84
+ Please see the "change log":http://github.com/pauldowman/ec2onrails/raw/master/gem/CHANGELOG for release notes, and see the "list of open issues":http://rubyforge.org/tracker/?atid=17558&group_id=4552&func=browse.
85
+
86
+ As is "standard for public AMI's":http://docs.amazonwebservices.com/AWSEC2/2007-08-29/DeveloperGuide/public-ami-guidelines.html, password-based logins are disabled. You log in with your own "public/private keypair":http://docs.amazonwebservices.com/AWSEC2/2007-08-29/GettingStartedGuide/running-an-instance.html.
87
+
88
+ Most basic things can be configured automatically by the Capistrano tasks, but if you want to you can login by ssh as a user named "admin" (has sudo ability) or as "app" (the user that the app runs as, does not have sudo ability). The Capistrano tasks automatically use the app user to deploy the app, and the admin user for server admin tasks that require sudo.
89
+
90
+ IMPORTANT: Double-check "your firewall settings":http://docs.amazonwebservices.com/AWSEC2/2007-08-29/GettingStartedGuide/running-an-instance.html. Be sure that you haven't allowed public access to any ports other than TCP 22 and TCP 80 (and possibly TCP 443 if you're going to enable HTTPS). If you're using multiple instances, be sure to allow them network access to each other.
91
+
92
+
93
+ h4. 4. Copy your public key from the server to keep Capistrano happy
94
+
95
+ This is a workaround for a quirk in Capistrano. Technically all you should need to connect to the server is the private key file, the public key is on the server. But for some reason "Capistrano requires that you have both the public key and the private key files together on the client":http://groups.google.com/group/capistrano/browse_thread/thread/1102208ff925d18.
96
+
97
+ There is a Capistrano task that tries to fix this for you. From within the root of your rails app do:
98
+
99
+ <pre>cap ec2onrails:get_public_key_from_server</pre>
100
+
101
+ Note, this will only work if you have an external ssh command in the path, it won't work for most Windows users.
102
+
103
+
104
+ h4. 5. Deploy the app with Capistrano
105
+
106
+ Now that the gem is installed, your deploy.rb is configured and you can start and stop EC2 instances, this is the only thing you'll need to do from now on.
107
+
108
+ <pre>
109
+ cap deploy:cold
110
+ </pre>
111
+
112
+ Yes, it's that easy! The setup task will set the server's timezone, install any gems and Ubuntu packages that you specified in the config file, and create your database.
113
+
114
+ That's it, your app is now running on EC2!!
115
+
116
+
117
+ h2. Capistrano tasks
118
+
119
+ "Capistrano":http://capify.org is the most commonly used Rails deployment tool. It comes with many standard "tasks", and the EC2 on Rails gem includes Capistrano tasks specifically for configuring the server instance.
120
+
121
+ Capistrano is run from the command-line using the "cap" command, with a task name given as an argument.
122
+
123
+ h3. Commonly-used tasks
124
+
125
+ You'll mostly need just the following Capistrano tasks:
126
+
127
+ * <code>cap ec2onrails:ami_ids</code> Shows the AMI id's of the images that match the current version of the gem.
128
+
129
+ * <code>cap ec2onrails:db:enable_ebs</code> This task will move the _primary_ mysql database onto an Amazon Elastic Storage Block (EBS) volume. You can call this task with the optional SIZE parameter defined (defaults to 10 gigs) like <pre>cap ec2onrails:db:enable_ebs SIZE=10</pre>
130
+
131
+ You should then specify your own volume (or the one created by this task) in your capistrano deploy.rb file like so: <pre>role :db, "ec2-xx-xxx-xx-xxx.compute-1.amazonaws.com", :primary => true, :ebs_vol_id => 'vol-12345abc'</pre>
132
+
133
+ *NOTE* MySQL EBS is not enabled by default. You may call this task at anytime to move your MySQL over to EBS, but just make sure you keep track of the volume-id that is printed out by this task and use it to modify your deploy.rb file
134
+
135
+ * <code>cap ec2onrails:server:set_roles</code> Customizes each instance for it's role(s) (as defined in your Capistrano deploy.rb file). Run this after starting or stopping instances. For now this just makes sure that only the appropriate services (Apache, Mongrel, and/or MySQL) are running. Eventually this will customize settings for the running services also. Note that an instance can have more than one role. If there's only one instance it will have all roles.
136
+
137
+ Note that due to the way that Capistrano works all tasks are run against all hosts that are currently defined in the deploy.rb file. So if you start a new instance then add it to your deploy.rb you will need to run "cap ec2onrails:setup" again which will be run on all existing instances.
138
+
139
+
140
+ h3. Database management tasks
141
+
142
+ * <code>cap ec2onrails:db:archive</code> Archive the MySQL database to the bucket specified in your deploy.rb. This is for archiving a snapshot of your database into any S3 bucket. For example, you might want to do this before deploying.
143
+
144
+ * <code>cap ec2onrails:db:restore</code> Restore the MySQL database from the bucket specified in your deploy.rb For example, I use this to restore the current production data (from my actual production backup bucket) onto a staging server that has the current production version of my app. I then deploy the new version which tests migrations exactly as they'll run on the production server.
145
+
146
+ To get a full list of the Capistrano tasks at any time type <code>cap -T</code> from with your rails app root.
147
+
148
+ h2. Building the image
149
+
150
+ The EC2 on Rails server image is built using "Eric Hammond's EC2 Ubuntu build script":http://alestic.com/
151
+
152
+ Note that building your own AMI is not necessary, other options are:
153
+ * Use one of the public AMI's and configure it at run-time (recommended).
154
+ * Re-bundle one of the public AMI's and save it as your own (not recommended because you won't be able to take advantage of any bug fixes or updates).
155
+
156
+
157
+ Instructions:
158
+
159
+ 1. Start an EC2 instance that will be used to run the build script. The recommended AMI's are Amazon's public developer images:
160
+ <pre>32-bit: ami-f51aff9c
161
+ 64-bit: ami-f21aff9b</pre>
162
+
163
+ 2. Copy your certificate file and private key file to the EC2 instance ephemeral storage, using your ssh _IDENTITY_ (key) file:
164
+ <pre>scp -i _IDENTITY_ pk-XXXXXXXXXX.pem root@_HOSTNAME_:/mnt/
165
+ scp -i _IDENTITY_ cert-XXXXXXXXXX.pem root@_HOSTNAME_:/mnt/</pre>
166
+
167
+ 3. Copy the entire ec2onrails source folder _EC2ONRAILS_ to the EC2 instance ephemeral storage, using your ssh IDENTITY file:
168
+ <pre>rsync -rlvzcC --delete --exclude='output*' --exclude='.git' --rsh='ssh -i _IDENTITY_' _EC2ONRAILS_ root@_HOSTNAME_:/mnt/</pre>
169
+ Note: make sure NOT to include a trailing slash on the ec2onrails directory name, rsync behaves differently when copying directories if there is no slash at the end of the folder name! After this step you should have a directory on the server named /mnt/ec2onrails (e.g. use /rails/ec2onrails not /rails/ec2onrails/ or /rails/ec2onrails/.)
170
+
171
+ 4. Using ssh, log in to the EC2 instance _HOSTNAME_ using your ssh _IDENTITY_ file:
172
+ <pre>ssh -i _IDENTITY_ root@_HOSTNAME_</pre>
173
+
174
+ 5. On the server, run the build script with the appropriate arguments: (_ARCH_ is either i386 or amd64)
175
+ <pre>ruby /mnt/ec2onrails/server/build \
176
+ --bucket ec2onrails \
177
+ --prefix ec2onrails-custom \
178
+ --arch _ARCH_
179
+ --user XXXX-XXXX-XXXX \
180
+ --access-key XXXXXXXXXX \
181
+ --secret-key XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
182
+ --private-key /mnt/pk-XXXXXXXXXX.pem \
183
+ --cert /mnt/cert-XXXXXXXXXX.pem</pre>
184
+
185
+ h2. Mailing lists
186
+
187
+ There are two Google groups, one for "announcements":http://groups.google.com/group/ec2-on-rails-announce (usually just new release announcements) and one for "discussion":http://groups.google.com/group/ec2-on-rails-discuss.
188
+
189
+
190
+ h2. Comments
191
+
192
+ Comments are welcome. Send an email to "Paul Dowman":http://pauldowman.com/contact/ or to the "Google group":http://groups.google.com/group/ec2-on-rails-discuss. If you find bugs please file them "here":http://rubyforge.org/tracker/?atid=17558&group_id=4552&func=browse or send me an "email":http://pauldowman.com/contact/.
193
+
194
+
195
+ h2. Change log
196
+
197
+ See the "change log":http://github.com/pauldowman/ec2onrails/raw/master/gem/CHANGELOG.
198
+
199
+
200
+ h2. How to submit patches
201
+
202
+ Please read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/. The source code can be checked out anonymously using:
203
+ <pre>
204
+ git clone git://github.com/pauldowman/ec2onrails.git
205
+ </pre>
206
+
207
+ Patches can be submitted to the "RubyForge Tracker":http://rubyforge.org/tracker/?atid=17560&group_id=4552&func=browse or "emailed directly to me":http://pauldowman.com/contact/ .
208
+
209
+ h2. Contributors
210
+
211
+ (In alphabetical order)
212
+
213
+ "Adam Greene":http://github.com/skippy
214
+ "Arpit Jain":http://github.com/arpitjain11
215
+ "Barry Paul":http://github.com/bpaul
216
+ "Ben Woosley":http://github.com/Empact
217
+ "Chris Nolan":http://github.com/ChrisNolan
218
+ Ed Wagner
219
+ "Mark Lane":http://github.com/DrMark
220
+ "Paul Dowman":http://github.com/pauldowman
221
+ "Pivotal Labs":http://github.com/pivotal
222
+ "Randy Harmon":http://github.com/rjharmon
223
+ "Robert J. Berger":http://github.com/rberger
224
+ "Sebastian Johnsson":http://github.com/Agiley
225
+ (If you've contributed code and you're not listed here I apologize, _please_ send me an email!)
226
+
227
+ h2. License
228
+
229
+ This code is free to use under the terms of the GPL v2.
230
+
231
+ If you find EC2 on Rails useful please "recommend Paul Dowman":http://www.workingwithrails.com/person/10131-paul-dowman at Working With Rails.
232
+
233
+ Copyright 2007 Paul Dowman, http://pauldowman.com/ This is free software, and you are welcome to redistribute it under certain conditions. This software comes with ABSOLUTELY NO WARRANTY. See the file named COPYING for details.
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ # This rakefile is for building the EC2 on Rails gem.
2
+ # To build a server AMI, see server/rakefile.rb
3
+
4
+ begin
5
+ require 'echoe'
6
+ rescue LoadError
7
+ abort "You'll need to have `echoe' installed to use ec2onrails' Rakefile"
8
+ end
9
+
10
+ require "./echoe_config"
11
+
12
+ desc "Run all gem-related tasks"
13
+ task :ec2onrails_gem => [:delete_ignored_files, :manifest, :package, :update_github_gemspec]
14
+
15
+ desc "Delete files that are in .gitignore so they don't get added to the manifest"
16
+ task :delete_ignored_files do
17
+ File.read(".gitignore").each { |line| FileUtils.rm_f Dir.glob(line.strip) }
18
+ end
19
+
20
+ desc "Update the GitHub gemspec file (/ec2onrails.gemspec)"
21
+ task :update_github_gemspec => [:manifest, :package] do
22
+ root_dir = File.dirname __FILE__
23
+ contents = File.open("#{root_dir}/pkg/ec2onrails-#{Ec2onrails::VERSION::STRING}/ec2onrails.gemspec", 'r').readlines
24
+ File.open("#{root_dir}/ec2onrails.gemspec", 'w') do |f|
25
+ f << "# This file is auto-generated, do not edit.\n"
26
+ f << "# Edit echoe_config.rb and then run 'rake ec2onrails_gem'\n"
27
+ f << "# \n"
28
+ contents.each {|line| f << line}
29
+ end
30
+ end
31
+
data/TODO ADDED
@@ -0,0 +1,104 @@
1
+ here are a list of upcoming changes or ones I'm thinking about
2
+
3
+ FUTURE CHANGES
4
+ [ ] when hardening server, change the SSH port
5
+
6
+ [ ] do not change the Capify file. This is an issue if you want to use ec2 for staging but something else (engineyard) for production. The issue is that require 'ec2onrails/recipes' cannot be called until after the deploy file has been run because of some loading dependencies. SO, is it possible to not have this behavior, or is this making a mnt out of a mole-hill?
7
+
8
+ [ ] be able to save an ami file after cap ec2onrails:setup is run... this way you can just launch more instances of that specific ami file (can we automate this? )
9
+
10
+ [ ] use mongrel_cluster from app directory (shared or directly in the app/config dir), and then default to the one at /etc/mongrel_cluster/app.yml
11
+
12
+ [ ] customize roles. For example, lets say I want to have nginx publish to multiple proxy's instead of the set_roles default ones. Have a hook where I, as an end user, can extend custom roles... but where do I put it? is there a custom_roles_file location pref that is set in the cap deploy file?
13
+
14
+ [ ] hook memcached into nginx...
15
+
16
+ [ ] hook ssl setup hooks for nginx
17
+
18
+ [ ] automatic firewall setup. The hitch is can we find the amazon user_id automatically?
19
+
20
+ [ ] automatic and randomized initial mysql root password setup. Place the root password in a text file only to be read by 'root', perhaps in /etc/ec2onrails/mysq_root_passwd. 'mysqladmin -u root -h localhost password subGen1us'
21
+
22
+ [ ] rename the root username for mysql, like 'update user set user="mydbadmin" where user="root";'. Make sure we do this at startup but also have a check that if a user is upgrading their server that this is switched
23
+
24
+ [ ] multi-database setup. Master -> n slave(s)
25
+
26
+ [ ] when generating roles file for each server, so each server knows where/how to find the internal IP of other servers in the cluster, generate this based on the roles that actually exist so arbitrary new ones can be added (recipes.rb, task :set_roles). Capistrano has a variable 'roles', that should be useable...? is an array, with Capistrano::ServerDefinition objects, which have the following attributes :host, :user, :port, :options
27
+
28
+ [ ] allow memcache servers to reside on a separate host/cluster
29
+
30
+ [ ] do a little memcache optimization, especially if it is its own host
31
+
32
+ [ ] allow to pull memcache file from application directory ./config
33
+
34
+ [ ] hook in pauls postfix changes to be able to use an external smtp provider. make it configurable:
35
+ http://pauldowman.com/2008/02/17/smtp-mail-from-ec2-web-server-setup/
36
+ also see this file for updates:
37
+ http://www.babbleon.co.uk/2008/05/email-with-ec2/
38
+
39
+ [ ] consolidate all logs to /mnt/log, including /mnt/app/current... it makes it easier to rotate and shuffle them off to s3
40
+
41
+ [ ] hook in encryption of backup archives
42
+
43
+ [ ] hook in backup of server... or should we wait for persistent storage snapshots? http://www.webmonkey.com/tutorial/Back_Up_a_Web_Server
44
+
45
+ [ ] allow a non-standard ssh port (and make sure the firewall is setup correctly). modify /etc/ssh/ssh_config, update /etc/services. Also turn off root access...but only if we have another full sudo user like 'admin'
46
+
47
+ [ ] should we go back to having a sudo user like 'admin' that we flip into when we need sudo access instead of root?
48
+
49
+ [ ] install and setup an intrusion detection system. Do we want to do something as simple fcheck(apt-get fcheck, run with fcheck -cadsxl, and add /mnt to its exclusion list?), or something more complex like snort or prelude? fcheck is small, but simple; snort is quite complex and will either require its own capistrano role or live on the web role... plus it needs to be hooked into email and other notification paths to make it useful.
50
+
51
+ [ ] make difficult security/hardening changes optional, especially if they will get in the way of getting up and running. For example, do not install denyhosts by default...or disable it if the security_hardening flag == false
52
+
53
+ POSSIBLE CHANGES
54
+ [ ] do not put users custom files up there until before deploy:cold? Right now I'm pushing a lot of custom stuff out there into monit which is failing because the code it is supposed to monitor is not there yet. will pushing it to "before 'deploy:cold' cause an issues"
55
+
56
+ [ ] possibly put /tmp on its own mnt point, and then lock it down in /etc/fstab. Modify tmp to something like this '/dev/hda2 /tmp ext3 nodev,nosuid, noexec 0 0'
57
+ this means nonone will be able to execute, or a bunch of other things, from within /tmp
58
+
59
+
60
+ QUESTIONS
61
+ * during setup, what do you choose for Postfix configurations? ANSWER:
62
+
63
+ * why install php5? ANSWER: Can't tell... seems to run fine without it, so removing it as a direct aptitude fetch (if it is a dependency somewhere else, it will get downloaded)
64
+
65
+ * WHO runs the script/migration? App or db? ANSWER: the (primary-) db does. This make sense in that you don't want every app instance running a rake db:migration. This means that the db role needs to be fully setup to handle rake db:migration, meaning the /etc/hosts file needs to contain db_primary as an alias to 127.0.0.1
66
+
67
+
68
+ COMPLETED
69
+ [X] preload mysql timezone information (UPDATE: not sure if this is needed...NOTE: it is not)
70
+
71
+ [X] mysql optimizations are not calculating the num of cores avail correctly
72
+
73
+ [X] right now cron has a task called 'app' in cron.daily, cron.hourly, cron.monthly, and cron.weekly. BUT, these are run on every server. we should probably provide some sort of mechanism so a user can specify particular jobs for particular roles NOTE: paul already thought of this with the exec_runner script that we can run from within cron
74
+
75
+ [X] get all user-data and meta-data variables from the amazon image in a similar way to rightscale? Makes it dead simple to use/manipulate that information. UPDATE: rightscale gave us permission to use their open-sourced files, as long as we credit them
76
+
77
+ [X] Move to Echoe? It just seems a LOT easier to setup and handle than hoe. It can remove a lot of cruft, probably including ./config, ./script, ./tasks (or most of them), and ./website (move that to the README file?... looks like would need to be moved to ./docs ). A few folks have branched ec2onrails into github before and they've all done this...
78
+
79
+ [X] set -y flag when installing/updating gems UPDATE: not needed... does it automatically for the other non-interactive flags we are using
80
+
81
+ [X] mysql optimizations
82
+
83
+ [X] hook in ebs, and use eric's writeup as the starting point:
84
+ http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1663&categoryID=100
85
+
86
+
87
+ [X] /etc/monit/monitrc needs to be chmod 700. see error at: http://pastie.org/251895, with custom task at http://pastie.org/251896.. Perhaps this should be solved in set_roles or init_services or something a bit higher`
88
+
89
+ [X] remove the *_admin capistrano roles. can we use admin for sudo access but continue to deploy and run under a user without sudo access? It looks like we can if we add this to the recipes.rb file:
90
+ set :use_sudo, true
91
+ set :user, "app"
92
+ set :admin_runner, "admin"
93
+ UPDATE: this didn't work as then admin would need to behave as root... SO, here is what I did:
94
+ * remove _admin roles AND the admin user
95
+ * give app user full sudo access to begin with
96
+ * have /etc/sudoers -> /etc/sudoers.full_access
97
+ * after ec2onrails:setup, trigger ec2onrails:server:restrict_sudo_access
98
+ - flips /etc/sudoers -> /etc/sudoers.restricted_access
99
+ - at this point, the app user ONLY has access to sudo to monit
100
+ * provide cap tasks to restrict or grant full sudo access
101
+
102
+ [X] allow config to be able to flip between nginx and apache as proxy...
103
+
104
+ [X] move to god from monit. One advantage is that right now, we don't use monit to send start/stop/restart signals to the underlying processes. Monit does not always stop mongrel, and if mongrel doesn't restart monit doesn't go in with the oh-holy 'kill -9'. So we unmonit mongrel, then use the /etc/init.d/mongrel stop to kill it. This works (quite well actually) BUT it makes it tricky because if we limit sudo access to only monit, we cannot run the /etc/init.d/*. It would be best if we provide sudo access to ONLY one process. God, supposedly, doesn't have this issue. So if we use god instead of monit, can we have god be responsible for restarts and what not?