-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrails-app-single.yaml
338 lines (300 loc) · 9.19 KB
/
rails-app-single.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
heat_template_version: 2013-05-23
description: |
#### Single Server - RCv3
Single Linux server running [Rails](http://rubyonrails.org/) and
[MySQL 5.5](http://www.mysql.com/) or
[Postgres 9.1](http://www.postgresql.org/).
This deployment is intended for development and testing scenarios.
This template will only function with RackConnect v3.
parameter_groups:
- label: Server Settings
parameters:
- flavor
- image
- label: RackConnect Settings
parameters:
- rc_network_name
- label: Rails Settings
parameters:
- domain
- database_username
- additional_packages
- ruby_version
- rails_environment
- rails_app_server
- rails_rake_tasks
- app_git_url
- app_git_revision
- label: rax-dev-params
# These are parameters that will not be displayed in the portal. The purpose
# of these parameters are for users who are developing or testing newer or
# different setups. If any of these parameters are changed, there is a good
# chance this stack will fail to properly deploy.
parameters:
- rails_db_adapter
- database_name
- kitchen
- chef_version
- rails_db_type
parameters:
# Server settings
image:
label: Operating System
description: |
Server image used for all servers that are created as a part of this
deployment
type: string
default: Ubuntu 12.04 LTS (Precise Pangolin) (PVHVM)
constraints:
- allowed_values:
- Ubuntu 12.04 LTS (Precise Pangolin) (PVHVM)
description: Must be a supported operating system.
flavor:
label: Server Size
description: |
Rackspace Cloud Server flavor to use. The size is based on the amount of
RAM for the provisioned server.
type: string
default: 4 GB General Purpose v1
constraints:
- allowed_values:
- 1 GB General Purpose v1
- 2 GB General Purpose v1
- 4 GB General Purpose v1
- 8 GB General Purpose v1
- 15 GB I/O v1
- 30 GB I/O v1
- 1GB Standard Instance
- 2GB Standard Instance
- 4GB Standard Instance
- 8GB Standard Instance
- 15GB Standard Instance
- 30GB Standard Instance
description: |
Must be a valid Rackspace Cloud Server flavor for the region you have
selected to deploy into.
additional_packages:
label: Additional Packages
description: |
A space-delimited list of Linux packages required to build the Gems
your application needs. Many commonly required packages are installed
by default, but you should list any you need here to ensure they are
present.
type: string
default: ''
rc_network_name:
type: string
label: RackConnect Network
description: Name or UUID of RackConnected network to attach this server to
constraints:
- custom_constraint: rackconnect.network
immutable: true
# Rails deployment
domain:
label: Site Domain
description: Domain to be used with the rails app site
type: string
default: "rails.example.com"
constraints:
- allowed_pattern: "^[a-zA-Z0-9.-]{1,255}.[a-zA-Z]{2,15}$"
description: Must be a valid domain name
ruby_version:
label: Ruby Version
description: Ruby version to be installed
type: string
default: 2.1.2
constraints:
- allowed_values:
- 2.1.2
- 2.0.0-p481
- 1.9.3-p547
rails_environment:
label: Rails Environment
description: Rails environment in which to deploy and run the application
type: string
default: production
rails_app_server:
label: Application Server
description: Application server to host your Rails application
type: string
default: unicorn
constraints:
- allowed_values:
- unicorn
- passenger
rails_db_type:
label: Database Type
description: The database server to be installed and configured
type: string
default: 'mysql'
constraints:
- allowed_values:
- mysql
- postgresql
rails_db_adapter:
label: Rails database adapter override
description: The Rails database adapter type to use if not mysql or postgresql
type: string
default: ''
rails_rake_tasks:
label: Rake Tasks
description: A space delimited list of rake tasks to run at deploy time
type: string
default: db:migrate assets:precompile
app_git_url:
label: Git URL
description: A git URL pointing to a repo containing your Rails application
type: string
default: ''
app_git_revision:
label: Git Revision
description: Git branch, tag, or commit hash to deploy.
type: string
default: master
app_git_deploy_key:
label: Git Deploy Key
description: |
Optional: A deploy key is only necessary if your git repository is
private.
type: string
default: ''
# Database and system user configuration
database_name:
label: Database Name
description: Database Name
type: string
default: railsapp_db
constraints:
- allowed_pattern: "^[0-9a-zA-Z$_]{1,64}$"
description: |
Maximum length of 64 characters, may only contain letters, numbers, and
underscores.
database_username:
label: Database Username
description: Database login for your Rails application
type: string
default: railsapp_user
constraints:
- allowed_pattern: "^(.){1,16}$"
description: |
Must be shorter than 16 characters, this is due to MySQL's maximum
username length.
kitchen:
label: Kitchen URL
description: "URL for a git repo containing required cookbooks"
type: string
default: https://github.com/rackspace-orchestration-templates/rails-app-single-rc
chef_version:
label: Chef Version
description: Version of chef client to use
type: string
default: 11.12.8
resources:
# Random password generation
database_user_password:
type: "OS::Heat::RandomString"
properties:
length: 16
sequence: lettersdigits
database_password:
type: "OS::Heat::RandomString"
properties:
length: 16
sequence: lettersdigits
db_admin_password:
type: "OS::Heat::RandomString"
properties:
length: 16
sequence: lettersdigits
mysql_repl_password:
type: "OS::Heat::RandomString"
properties:
length: 16
sequence: lettersdigits
mysql_debian_password:
type: "OS::Heat::RandomString"
properties:
length: 16
sequence: lettersdigits
# SSH key
ssh_key:
type: "OS::Nova::KeyPair"
properties:
name: { get_param: "OS::stack_id" }
save_private_key: true
# Server resources
rails_server:
type: "OS::Nova::Server"
properties:
name: rails
flavor: { get_param: flavor }
image: { get_param: image }
key_name: { get_resource: ssh_key }
networks:
- network: { get_param: rc_network_name }
- network: 11111111-1111-1111-1111-111111111111
metadata:
rax-heat: { get_param: "OS::stack_id" }
rails_server_public_ip:
type: Rackspace::RackConnect::PublicIP
depends_on: rails_server
properties:
server_id: { get_resource: rails_server }
# Chef resources
rails_setup:
type: "OS::Heat::ChefSolo"
depends_on: rails_server
properties:
username: root
private_key: { get_attr: [ssh_key, private_key] }
host: { get_attr: [rails_server, networks, private, 0] }
kitchen: { get_param: kitchen }
chef_version: { get_param: chef_version }
node:
railsstack:
standalone: true
app_server: { get_param: rails_app_server}
web_server: ''
ruby_version: { get_param: ruby_version }
git_url: { get_param: app_git_url }
git_revision: { get_param: app_git_revision }
git_deploy_key: { get_param: app_git_deploy_key }
additional_packages: { get_param: additional_packages }
db:
type: { get_param: rails_db_type }
hostname: 'localhost'
user_id: { get_param: database_username }
user_password: { get_resource: database_user_password }
rails:
environment: { get_param: rails_environment }
db_adapter: { get_param: rails_db_adapter }
rake_tasks: { get_param: rails_rake_tasks }
mysql:
bind_address: "127.0.0.1"
server_root_password: { get_attr: [db_admin_password, value] }
server_repl_password: { get_attr: [mysql_repl_password, value] }
server_debian_password: { get_attr: [mysql_debian_password, value] }
remove_test_database: true
remove_anonymous_users: true
postgresql:
password:
postgres: { get_attr: [db_admin_password, value] }
build-essential:
compile_time: true
run_list: ["recipe[apt]",
"recipe[rax-rails-app::db_setup]",
"recipe[rax-rails-app::heat_deploy_app]"]
outputs:
private_key:
value: { get_attr: [ssh_key, private_key] }
description: "SSH Private Key"
server_ip:
value: { get_attr: [rails_server, accessIPv4] }
description: "Server IP"
rails_app_url:
value:
str_replace:
template: "http://%server_ip%"
params:
"%server_ip%": { get_attr: [ rails_server, accessIPv4 ] }
description: Application URL