axtro-rubber 1.0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/CHANGELOG +39 -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 +41 -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 +5 -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 +62 -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 +30 -0
  18. data/generators/vulcanize/templates/apache/config/rubber/rubber-apache.yml +7 -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/config/deploy.rb +55 -0
  22. data/generators/vulcanize/templates/base/config/rubber/common/crontab +16 -0
  23. data/generators/vulcanize/templates/base/config/rubber/common/profile.rc +9 -0
  24. data/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +104 -0
  25. data/generators/vulcanize/templates/base/config/rubber/rubber.yml +241 -0
  26. data/generators/vulcanize/templates/base/lib/tasks/rubber.rake +15 -0
  27. data/generators/vulcanize/templates/base/script/cron-rake +18 -0
  28. data/generators/vulcanize/templates/base/script/cron-runner +18 -0
  29. data/generators/vulcanize/templates/base/script/cron-sh +67 -0
  30. data/generators/vulcanize/templates/base/templates.yml +1 -0
  31. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/haproxy/haproxy-mongrel.conf +23 -0
  32. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/nginx/nginx-mongrel.conf +113 -0
  33. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/rubber-complete.yml +41 -0
  34. data/generators/vulcanize/templates/complete_mongrel_mysql/templates.yml +6 -0
  35. data/generators/vulcanize/templates/complete_passenger_mysql/config/rubber/role/haproxy/haproxy-passenger.conf +19 -0
  36. data/generators/vulcanize/templates/complete_passenger_mysql/config/rubber/rubber-complete.yml +40 -0
  37. data/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +10 -0
  38. data/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +72 -0
  39. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/cruise +40 -0
  40. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/my.cnf +165 -0
  41. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/production.rb +8 -0
  42. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/site_config.rb +76 -0
  43. data/generators/vulcanize/templates/cruise/config/rubber/role/web_tools/cruise-nginx.conf +11 -0
  44. data/generators/vulcanize/templates/cruise/config/rubber/rubber-cruise.yml +18 -0
  45. data/generators/vulcanize/templates/cruise/templates.yml +1 -0
  46. data/generators/vulcanize/templates/haproxy/config/rubber/deploy-haproxy.rb +45 -0
  47. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-base.conf +26 -0
  48. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-default.conf +8 -0
  49. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +9 -0
  50. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf +6 -0
  51. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslogd-default.conf +17 -0
  52. data/generators/vulcanize/templates/haproxy/config/rubber/role/web_tools/haproxy-nginx.conf +10 -0
  53. data/generators/vulcanize/templates/haproxy/config/rubber/rubber-haproxy.yml +7 -0
  54. data/generators/vulcanize/templates/haproxy/templates.yml +1 -0
  55. data/generators/vulcanize/templates/memcached/config/memcached.yml +28 -0
  56. data/generators/vulcanize/templates/memcached/config/rubber/common/memcached.yml +14 -0
  57. data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached.conf +52 -0
  58. data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached_munin_plugin +249 -0
  59. data/generators/vulcanize/templates/memcached/config/rubber/rubber-memcached.yml +7 -0
  60. data/generators/vulcanize/templates/memcached/templates.yml +1 -0
  61. data/generators/vulcanize/templates/minimal_mysql/templates.yml +7 -0
  62. data/generators/vulcanize/templates/minimal_nodb/templates.yml +6 -0
  63. data/generators/vulcanize/templates/mongrel/config/rubber/deploy-mongrel.rb +75 -0
  64. data/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/mongrel_cluster.yml +12 -0
  65. data/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/monit-mongrel.conf +20 -0
  66. data/generators/vulcanize/templates/mongrel/config/rubber/rubber-mongrel.yml +9 -0
  67. data/generators/vulcanize/templates/mongrel/templates.yml +1 -0
  68. data/generators/vulcanize/templates/monit/config/rubber/common/monit-default.conf +15 -0
  69. data/generators/vulcanize/templates/monit/config/rubber/common/monit.conf +251 -0
  70. data/generators/vulcanize/templates/monit/config/rubber/deploy-monit.rb +32 -0
  71. data/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +10 -0
  72. data/generators/vulcanize/templates/monit/config/rubber/rubber-monit.yml +6 -0
  73. data/generators/vulcanize/templates/monit/templates.yml +1 -0
  74. data/generators/vulcanize/templates/munin/config/rubber/common/monit-munin.conf +8 -0
  75. data/generators/vulcanize/templates/munin/config/rubber/common/munin-node.conf +48 -0
  76. data/generators/vulcanize/templates/munin/config/rubber/deploy-munin.rb +46 -0
  77. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-nginx.conf +8 -0
  78. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-plugins.conf +31 -0
  79. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +80 -0
  80. data/generators/vulcanize/templates/munin/config/rubber/rubber-munin.yml +8 -0
  81. data/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +57 -0
  82. data/generators/vulcanize/templates/munin/script/munin/example_simple.rb +24 -0
  83. data/generators/vulcanize/templates/munin/templates.yml +1 -0
  84. data/generators/vulcanize/templates/mysql/config/rubber/common/database.yml +11 -0
  85. data/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +156 -0
  86. data/generators/vulcanize/templates/mysql/config/rubber/role/db/crontab +14 -0
  87. data/generators/vulcanize/templates/mysql/config/rubber/role/db/monit-mysql.cnf +10 -0
  88. data/generators/vulcanize/templates/mysql/config/rubber/role/db/my.cnf +167 -0
  89. data/generators/vulcanize/templates/mysql/config/rubber/role/mysql_slave/mysql_slave_munin_plugin +51 -0
  90. data/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +46 -0
  91. data/generators/vulcanize/templates/mysql/templates.yml +1 -0
  92. data/generators/vulcanize/templates/mysql_cluster/config/rubber/common/mysql_cluster_migrations.rb +13 -0
  93. data/generators/vulcanize/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb +173 -0
  94. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_data/my.cnf +15 -0
  95. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_mgm/ndb_mgmd.cnf +39 -0
  96. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf +10 -0
  97. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/my.cnf +23 -0
  98. data/generators/vulcanize/templates/mysql_cluster/config/rubber/rubber-mysql_cluster.yml +32 -0
  99. data/generators/vulcanize/templates/mysql_cluster/templates.yml +1 -0
  100. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/database.yml +16 -0
  101. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf +10 -0
  102. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +153 -0
  103. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.conf +10 -0
  104. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.lua +5 -0
  105. data/generators/vulcanize/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb +52 -0
  106. data/generators/vulcanize/templates/mysql_proxy/config/rubber/rubber-mysql_proxy.yml +11 -0
  107. data/generators/vulcanize/templates/mysql_proxy/templates.yml +1 -0
  108. data/generators/vulcanize/templates/nginx/config/rubber/deploy-nginx.rb +45 -0
  109. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/crontab +9 -0
  110. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/monit-nginx.conf +8 -0
  111. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/nginx.conf +42 -0
  112. data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
  113. data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-index.html +30 -0
  114. data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
  115. data/generators/vulcanize/templates/nginx/config/rubber/rubber-nginx.yml +10 -0
  116. data/generators/vulcanize/templates/nginx/templates.yml +1 -0
  117. data/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +37 -0
  118. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +6 -0
  119. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +47 -0
  120. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf +46 -0
  121. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +10 -0
  122. data/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +12 -0
  123. data/generators/vulcanize/templates/passenger/templates.yml +1 -0
  124. data/generators/vulcanize/templates/sphinx/config/rubber/common/sphinx.yml +46 -0
  125. data/generators/vulcanize/templates/sphinx/config/rubber/deploy-sphinx.rb +112 -0
  126. data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/crontab +11 -0
  127. data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf +10 -0
  128. data/generators/vulcanize/templates/sphinx/config/rubber/rubber-sphinx.yml +6 -0
  129. data/generators/vulcanize/templates/sphinx/templates.yml +1 -0
  130. data/generators/vulcanize/vulcanize_generator.rb +67 -0
  131. data/lib/capistrano/hostcmd.rb +12 -0
  132. data/lib/rubber.rb +38 -0
  133. data/lib/rubber/capistrano.rb +1 -0
  134. data/lib/rubber/cloud.rb +13 -0
  135. data/lib/rubber/cloud/aws.rb +305 -0
  136. data/lib/rubber/cloud/base.rb +16 -0
  137. data/lib/rubber/configuration.rb +47 -0
  138. data/lib/rubber/dns.rb +13 -0
  139. data/lib/rubber/dns/base.rb +69 -0
  140. data/lib/rubber/dns/dyndns.rb +63 -0
  141. data/lib/rubber/dns/nettica.rb +73 -0
  142. data/lib/rubber/dns/zerigo.rb +131 -0
  143. data/lib/rubber/environment.rb +161 -0
  144. data/lib/rubber/generator.rb +197 -0
  145. data/lib/rubber/instance.rb +165 -0
  146. data/lib/rubber/recipes/rubber.rb +89 -0
  147. data/lib/rubber/recipes/rubber/bundles.rb +28 -0
  148. data/lib/rubber/recipes/rubber/deploy.rb +90 -0
  149. data/lib/rubber/recipes/rubber/instances.rb +348 -0
  150. data/lib/rubber/recipes/rubber/load_balancers.rb +44 -0
  151. data/lib/rubber/recipes/rubber/security_groups.rb +189 -0
  152. data/lib/rubber/recipes/rubber/setup.rb +357 -0
  153. data/lib/rubber/recipes/rubber/static_ips.rb +107 -0
  154. data/lib/rubber/recipes/rubber/utils.rb +203 -0
  155. data/lib/rubber/recipes/rubber/volumes.rb +264 -0
  156. data/lib/rubber/tasks/rubber.rb +221 -0
  157. data/lib/rubber/util.rb +37 -0
  158. data/test/environment_test.rb +118 -0
  159. data/test/generator_test.rb +323 -0
  160. data/test/instance_test.rb +93 -0
  161. data/test/test_helper.rb +4 -0
  162. data/test/util_test.rb +16 -0
  163. metadata +274 -0
@@ -0,0 +1,241 @@
1
+ # All variables can also be overridden on the role and/or host level by creating
2
+ # a sub level to the config under roles and hosts
3
+ # e.g. to install mysql only on db role, and awstats only on web01:
4
+ #
5
+ # packages: [ruby]
6
+ # roles:
7
+ # db:
8
+ # packages: [mysql]
9
+ # hosts:
10
+ # web01:
11
+ # packages: [awstats]
12
+
13
+ # REQUIRED: The name of your application
14
+ app_name: your_app_name
15
+
16
+ # REQUIRED: The system user to run your app servers as
17
+ app_user: app
18
+
19
+ # REQUIRED: Notification emails (e.g. monit) get sent to this address
20
+ #
21
+ admin_email: root@localhost
22
+
23
+ # OPTIONAL: If not set, you won't be able to access web_tools
24
+ # server (munin stats, monit status, etc)
25
+ # web_tools_user: admin
26
+ # web_tools_password: sekret
27
+
28
+ # REQUIRED: The timezone the server should be in
29
+ timezone: US/Eastern
30
+
31
+ # REQUIRED: the domain all the instances should be associated with
32
+ #
33
+ domain: foo.com
34
+
35
+ # OPTIONAL: The configuration for each dns provider (nettica|zerigo|dyndns)
36
+ # This lets rubber updatea dynamic dns service with the instance alias and ip
37
+ #
38
+ dns_providers:
39
+ nettica:
40
+ user: joe
41
+ password: sekret
42
+ record_type: A
43
+ ttl: 300
44
+ zerigo:
45
+ customer_id: 1234
46
+ email: foo@bar.com
47
+ token: hexxy
48
+ record_type: A
49
+ ttl: 300
50
+ dyndns:
51
+ user: joe
52
+ password: sekret
53
+ update_url: https://members.dyndns.org/nic/update?hostname=%host%&myip=%ip%'
54
+
55
+ # OPTIONAL: The dns provider to use
56
+ # dns_provider: nettica
57
+
58
+ # OPTIONAL: Additional rubber file to pull config from if it exists. This file will
59
+ # also be pushed to remote host at RUBBER_ROOT/config/rubber/rubber-secret.yml
60
+ #
61
+ # rubber_secret: "#{File.expand_path('~') + '/.ec2' + (RUBBER_ENV == 'production' ? '' : '_dev') + '/rubber-secret.yml' rescue ''}"
62
+
63
+ # REQUIRED All known cloud providers with the settings needed to configure them
64
+ # There's only one coud provider right now - Amazon Web Services
65
+ # To implement another, clone lib/rubber/cloud/aws.rb
66
+ #
67
+ cloud_providers:
68
+ aws:
69
+ # REQUIRED The amazon keys and account ID (digits only, no dashes) used to access the AWS API
70
+ #
71
+ access_key: XXX
72
+ secret_access_key: YYY
73
+ account: ZZZ
74
+
75
+ # REQUIRED: The name of the amazon keypair and location of its private key
76
+ #
77
+ # NOTE: for some reason Capistrano requires you to have both the public and
78
+ # the private key in the same folder, the public key should have the
79
+ # extension ".pub". The easiest (only?) way to get your hand on this is to
80
+ # create an instance, ssh into it, and copy the file /mnt/openssh_id.pub
81
+ #
82
+ key_name: gsg-keypair
83
+ key_file: "#{Dir[(File.expand_path('~') rescue '/root') + '/.ec2/*' + cloud_providers.aws.key_name].first}"
84
+
85
+ # OPTIONAL: Needed for bundling a running instance using rubber:bundle
86
+ #
87
+ # pk_file: "#{Dir[(File.expand_path('~') rescue '/root') + '/.ec2/pk-*'].first}"
88
+ # cert_file: "#{Dir[(File.expand_path('~') rescue '/root') + '/.ec2/cert-*'].first}"
89
+ # image_bucket: "#{app_name}_images"
90
+
91
+ # OPTIONAL: Needed for backing up database to s3
92
+ # backup_bucket: "#{app_name}_backups"
93
+
94
+ # REQUIRED: the ami and instance type for creating instances
95
+ # The Ubuntu images at http://alestic.com/ work well
96
+ # Ubuntu 9.04 Jaunty base install 32-bit 2.6.21.7-2.fc8xen ami-ed46a784
97
+ # Ubuntu 9.04 Jaunty base install 64-bit 2.6.21.7-2.fc8xen ami-5b46a732
98
+ #
99
+ image_id: ami-ed46a784
100
+ # m1.small or m1.large or m1.xlarge
101
+ image_type: m1.small
102
+
103
+ # REQUIRED the cloud provider to use
104
+ #
105
+ cloud_provider: aws
106
+
107
+ # OPTIONAL: Define security groups
108
+ # Each security group is a name associated with a sequence of maps where the
109
+ # keys are the parameters to the ec2 AuthorizeSecurityGroupIngress API
110
+ # source_security_group_name, source_security_group_owner_id
111
+ # ip_protocol, from_port, to_port, cidr_ip
112
+ #
113
+ security_groups:
114
+ default:
115
+ description: The default security group
116
+ rules:
117
+ - source_group_name: default
118
+ source_group_account: "#{cloud_providers.aws.account}"
119
+ - protocol: tcp
120
+ from_port: 22
121
+ to_port: 22
122
+ source_ips: [0.0.0.0/0]
123
+
124
+ # OPTIONAL: The default security groups to create instances with
125
+ assigned_security_groups: [default]
126
+
127
+ # OPTIONAL: Automatically create security groups for each host and role
128
+ # EC2 doesn't allow one to change what groups an instance belongs to after
129
+ # creation, so its good to have some empty ones predefined.
130
+ auto_security_groups: true
131
+
132
+ # OPTIONAL: Automatically isolate security groups for each appname/environment
133
+ # by mangling their names to be appname_env_groupname
134
+ # This makes it safer to have staging and production coexist on the same EC2
135
+ # account, or even multiple apps
136
+ isolate_security_groups: true
137
+
138
+ # OPTIONAL: Set if you want to use Ruby Enterprise Edition instead of the standard ubuntu one
139
+ use_enterprise_ruby: false
140
+
141
+ # OPTIONAL: The packages to install on all instances
142
+ # You can install a specific version of a package by using a sub-array of pkg, version
143
+ # For example, packages: [[rake, 0.7.1], irb]
144
+ packages: [postfix, build-essential, ruby-full, ruby1.8-dev, rake, irb]
145
+
146
+ # OPTIONAL: gem sources to setup for rubygems
147
+ gemsources: ["http://gems.rubyforge.org/", "http://gems.github.com"]
148
+
149
+ # OPTIONAL: The gems to install on all instances
150
+ # You can install a specific version of a gem by using a sub-array of gem, version
151
+ # For example, gem: [[rails, 2.2.2], open4, aws-s3]
152
+ gems: [wr0ngway-rubber, rails, open4, aws-s3]
153
+
154
+ # OPTIONAL: A string prepended to shell command strings that cause multi
155
+ # statement shell commands to fail fast. You may need to comment this out
156
+ # on some platforms, but it works for me on linux/osx with a bash shell
157
+ #
158
+ stop_on_error_cmd: "function error_exit { exit 99; }; trap error_exit ERR"
159
+
160
+ # OPTIONAL: The default set of roles to use when creating a staging instance
161
+ # with "cap rubber:create_staging". By default this uses all the known roles,
162
+ # but this is not always desired for staging, so you can specify a different
163
+ # set here
164
+ #
165
+ staging_roles: "web,app,db:primary=true"
166
+
167
+
168
+ # OPTIONAL: Lets one assign amazon elastic IPs (static IPs) to your instances
169
+ # You should typically set this on the role/host level rather than
170
+ # globally , unless you really do want all instances to have a
171
+ # static IP
172
+ #
173
+ # use_static_ip: true
174
+
175
+ # OPTIONAL: Specifies an instance to be created in the given availability zone
176
+ # Availability zones are sepcified by amazon to be somewhat isolated
177
+ # from each other so that hardware failures in one zone shouldn't
178
+ # affect instances in another. As such, it is good to specify these
179
+ # for instances that need to be redundant to reduce your chance of
180
+ # downtime. You should typically set this on the role/host level
181
+ # rather than globally. Use rubber describe:zones to see the list
182
+ # of zones
183
+ # availability_zone: us-east-1a
184
+
185
+ # OPTIONAL: If you want t use Elastic Block Store (EBS) persistent
186
+ # volumes, add them to host specific overrides and they will get created
187
+ # and assigned to the instance. On initial creation, the volume will get
188
+ # attached _and_ formatted, but if your host disapears and you recreate
189
+ # it, the volume will only get remounted thereby preserving your data
190
+ #
191
+ # hosts:
192
+ # my_host:
193
+ # availability_zone: us-east-1a
194
+ # volumes:
195
+ # - size: 100 # size of vol in GBs
196
+ # zone: us-east-1a # zone to create volume in, needs to match host's zone
197
+ # device: /dev/sdh # OS device to attach volume to
198
+ # mount: /mnt/mysql # The directory to mount this volume to
199
+ # filesystem: ext3 # the filesystem to create on volume
200
+ # - size: 10 # size of vol in GBs
201
+ # zone: us-east-1a # zone to create volume in, needs to match host's zone
202
+ # device: /dev/sdi # OS device to attach volume to
203
+ # mount: /mnt/logs # The directory to mount this volume to
204
+ # filesystem: ext3 # the filesystem to create on volume
205
+ #
206
+ # # volumes without mount/filesystem can be used in raid arrays
207
+ #
208
+ # - size: 50 # size of vol in GBs
209
+ # zone: us-east-1a # zone to create volume in, needs to match host's zone
210
+ # device: /dev/sdx # OS device to attach volume to
211
+ # - size: 50 # size of vol in GBs
212
+ # zone: us-east-1a # zone to create volume in, needs to match host's zone
213
+ # device: /dev/sdy # OS device to attach volume to
214
+ #
215
+ # # for raid array, you'll need to add mdadm to packages. Likewise,
216
+ # # xfsprogs is needed for xfs filesystem support
217
+ # packages: [xfsprogs, mdadm]
218
+ # raid_volumes:
219
+ # - device: /dev/md0 # OS device to to create raid array on
220
+ # mount: /mnt/fast # The directory to mount this array to
221
+ # filesystem: xfs # the filesystem to create on array
222
+ # raid_level: 0 # the raid level to use for the array
223
+ # source_devices: [/dev/sdx, /dev/sdy] # the source EBS devices we are creating raid array from
224
+
225
+ # OPTIONAL: You can also define your own variables here for use when
226
+ # transforming config files, and they will be available in your config
227
+ # templates as <%= rubber_env.var_name %>
228
+ #
229
+ # var_name: var_value
230
+
231
+ # OPTIONAL: Role specific overrides
232
+ # roles:
233
+ # somerole:
234
+ # packages: []
235
+ # somerole2:
236
+ # myconfig: someval
237
+
238
+ # OPTIONAL: Host specific overrides
239
+ # hosts:
240
+ # somehost:
241
+ # packages: []
@@ -0,0 +1,15 @@
1
+ # rails tries to load this from generator dir, so skip it.
2
+ if __FILE__ !~ /rubber\/generators\/vulcanize/
3
+
4
+ env = ENV['RUBBER_ENV'] ||= (ENV['RAILS_ENV'] || 'development')
5
+ root = File.dirname(__FILE__) + '/../..'
6
+
7
+ # this tries first as a rails plugin then as a gem
8
+ $:.unshift "#{root}/vendor/plugins/rubber/lib/"
9
+ require 'rubber'
10
+
11
+ Rubber::initialize(root, env)
12
+
13
+ require 'rubber/tasks/rubber'
14
+
15
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # For running rake jobs through cron - only prints output if there is an error
4
+ #
5
+ # author mconway
6
+ # since 8/12/07
7
+
8
+ RAILS_ROOT = File.expand_path("..", File.dirname(__FILE__))
9
+ log = "#{RAILS_ROOT}/log/cron-rake-#{Time.now.tv_sec}.log"
10
+ begin
11
+ ident = File.basename(ARGV[-1]).gsub(/\W+/, "_")
12
+ log = "#{RAILS_ROOT}/log/cron-rake-#{ident}.log"
13
+ rescue
14
+ end
15
+
16
+ Dir.chdir(RAILS_ROOT)
17
+ args = %W{-l #{log} -- rake --trace} + ARGV
18
+ system "script/cron-sh", *args
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # For running jobs through cron - only prints output if there is an error
4
+ #
5
+ # author mconway
6
+ # since 8/12/07
7
+
8
+ RAILS_ROOT = File.expand_path("..", File.dirname(__FILE__))
9
+ log = "#{RAILS_ROOT}/log/cron-runner-#{Time.now.tv_sec}.log"
10
+ begin
11
+ ident = File.basename(ARGV[-1]).gsub(/\W+/, "_")
12
+ log = "#{RAILS_ROOT}/log/cron-runner-#{ident}.log"
13
+ rescue
14
+ end
15
+
16
+ Dir.chdir(RAILS_ROOT)
17
+ args = %W{-e -l #{log} -- script/runner} + ARGV
18
+ system "script/cron-sh", *args
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # For running shell commands through cron - only prints output if there is an error
4
+ #
5
+ # author mconway
6
+ # since 8/12/07
7
+
8
+ require 'optparse'
9
+ require 'ostruct'
10
+ require 'rubygems'
11
+ require 'open4'
12
+
13
+ options = OpenStruct.new
14
+ options.logfile = "/tmp/cron-sh-#{Time.now.tv_sec}.log"
15
+ options.echoerr = false
16
+ options.echoout = false
17
+
18
+ opts = OptionParser.new do |opts|
19
+ opts.banner = "Usage: cron-sh [options] <shell command>"
20
+ opts.separator "Runs the given command, sending all stdout/stderr to a logfile, but echoing"
21
+ opts.separator "the entire file if the command exits with an error"
22
+ opts.separator ""
23
+ opts.separator "Specific options:"
24
+
25
+ opts.on("-l", "--log logfile", "Log to given file instead of a default") do |val|
26
+ options.logfile = val
27
+ end
28
+
29
+ opts.on("-o", "--[no-]echoout", "Log _and_ echo stdout") do |val|
30
+ options.echoout = true
31
+ end
32
+
33
+ opts.on("-e", "--[no-]echoerr", "Log _and_ echo stderr") do |val|
34
+ options.echoerr = true
35
+ end
36
+
37
+ opts.on_tail("-h", "--help", "Show this message") do
38
+ puts opts
39
+ exit
40
+ end
41
+ end
42
+
43
+ cmd = opts.parse(ARGV)
44
+
45
+ status = Open4::popen4(*cmd) do |pid, stdin, stdout, stderr|
46
+ File.open(options.logfile, "w") do | fh |
47
+ threads = []
48
+ threads << Thread.new(stdout) do |stdout|
49
+ stdout.each { |line| $stdout.puts line if options.echoout; fh.print line; fh.flush }
50
+ end
51
+ threads << Thread.new(stderr) do |stderr|
52
+ stderr.each { |line| $stderr.puts line if options.echoerr; fh.print line; fh.flush }
53
+ end
54
+ threads.each { |t| t.join }
55
+ end
56
+ end
57
+
58
+ result = status.exitstatus
59
+ if result != 0
60
+ puts ""
61
+ puts "*** Process exited with non-zero error code, full output follows"
62
+ puts "*** Command was: #{cmd.join(' ')}"
63
+ puts ""
64
+ puts IO.read(options.logfile)
65
+ end
66
+
67
+ exit(result)
@@ -0,0 +1 @@
1
+ description: The core configuration needed by all others
@@ -0,0 +1,23 @@
1
+ <%
2
+ @path = "/etc/haproxy/haproxy.cfg"
3
+ @additive = ["# start haproxy mongrel", "# end haproxy mongrel"]
4
+ %>
5
+
6
+ listen mongrel_proxy 0.0.0.0:<%= rubber_env.haproxy_listen_port %>
7
+ <%
8
+ # Since we do "fair" load balancing to the mongrels, we don't want to share mongrels
9
+ # between haproxy instances otherwise we still end up with requests getting queued behind
10
+ # slow ones.
11
+ mongrel_hosts = rubber_instances.for_role('mongrel').collect { |i| i.name }
12
+ haproxy_hosts = rubber_instances.for_role('haproxy').collect { |i| i.name }
13
+ ports = (rubber_env.mongrel_base_port.to_i ... rubber_env.mongrel_base_port.to_i + rubber_env.mongrel_count.to_i).to_a
14
+ host_count = haproxy_hosts.size
15
+ host_mod = haproxy_hosts.sort.index(rubber_env.host) rescue 0
16
+ ports = ports.find_all {|x| x % host_count == host_mod}
17
+ %>
18
+ <% mongrel_hosts.each do |server| %>
19
+ <% ports.each do |port| %>
20
+ server <%= server %>_<%= port %> <%= server %>:<%= port %> maxconn 1 check
21
+ <% end %>
22
+ <% end %>
23
+
@@ -0,0 +1,113 @@
1
+ <%
2
+ @path = "/etc/nginx/rubber/mongrel.conf"
3
+ %>
4
+
5
+ upstream haproxy_mongrel
6
+ {
7
+ <% rubber_instances.for_role('haproxy').each do |ic| %>
8
+ server <%= ic.name %>:<%= rubber_env.haproxy_listen_port %>;
9
+ <% end %>
10
+ }
11
+
12
+
13
+ <% %w[http https].each do |protocol| %>
14
+
15
+ # This server is setup to serve www over <%= protocol %>.
16
+ server
17
+ {
18
+ <% if protocol == 'https' %>
19
+ listen <%= rubber_env.web_ssl_port %>;
20
+ ssl on;
21
+ ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
22
+ ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
23
+ # ssl_certificate <%= RUBBER_ROOT %>/config/snapmylife.com.crt;
24
+ # ssl_certificate_key <%= RUBBER_ROOT %>/config/snapmylife.com.key;
25
+ <% else %>
26
+ listen <%= rubber_env.web_port %>;
27
+ <% end %>
28
+
29
+ client_max_body_size 10M;
30
+
31
+ server_name <%= rubber_env.domain %>;
32
+
33
+ if ( $host = www.<%= rubber_env.domain %>)
34
+ {
35
+ rewrite ^\/(.*)$ http://<%= rubber_env.domain %>/$1 permanent;
36
+ }
37
+
38
+ root <%= RUBBER_ROOT + "/public" %>;
39
+
40
+ # this rewrites all the requests to the maintenance.html
41
+ # page if it exists in the doc root. This is for capistrano's
42
+ # disable web task
43
+ if (-f $document_root/system/maintenance.html)
44
+ {
45
+ rewrite ^(.*)$ /system/maintenance.html last;
46
+ break;
47
+ }
48
+
49
+ location /
50
+ {
51
+ <%# nginx -> rails is http, so this tells rails the source protocol was https %>
52
+ <%= 'proxy_set_header X_FORWARDED_PROTO https;' if protocol == 'https' %>
53
+
54
+ # needed to forward user's IP address to rails
55
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
56
+
57
+ # needed for HTTPS
58
+ proxy_set_header Host $http_host;
59
+ proxy_redirect false;
60
+ proxy_max_temp_file_size 0;
61
+
62
+
63
+ # If the file exists as a static file serve it directly without
64
+ # running all the other rewrite tests on it
65
+ if (-f $request_filename)
66
+ {
67
+ break;
68
+ }
69
+
70
+ # check for index.html for directory index
71
+ # if its there on the filesystem then rewite
72
+ # the url to add /index.html to the end of it
73
+ # and then break to send it to the next config rules.
74
+ if (-f $request_filename/index.html)
75
+ {
76
+ rewrite (.*) $1/index.html break;
77
+ }
78
+
79
+ # this is the meat of the rails page caching config
80
+ # it adds .html to the end of the url and then checks
81
+ # the filesystem for that file. If it exists, then we
82
+ # rewite the url to have explicit .html on the end
83
+ # and then send it on its way to the next config rule.
84
+ # if there is no file on the fs then it sets all the
85
+ # necessary headers and proxies to our upstream mongrels
86
+ if (-f $request_filename.html)
87
+ {
88
+ rewrite (.*) $1.html break;
89
+ }
90
+
91
+ if (!-f $request_filename)
92
+ {
93
+ proxy_pass http://haproxy_mongrel;
94
+ break;
95
+ }
96
+ }
97
+
98
+ # catch errors from proxy so we can display our error page
99
+ proxy_intercept_errors on;
100
+
101
+ error_page 500 502 503 504 /500.html;
102
+ location = /500.html
103
+ {
104
+ root <%= RUBBER_ROOT + "/public" %>;
105
+ }
106
+ error_page 404 /404.html;
107
+ location = /404.html
108
+ {
109
+ root <%= RUBBER_ROOT + "/public" %>;
110
+ }
111
+ }
112
+
113
+ <% end %>