/
wordpress-multi-server.yaml
723 lines (664 loc) · 22.3 KB
/
wordpress-multi-server.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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
heat_template_version: 2013-05-23
description: |
#### Multiple Servers
Multiple [WordPress](https://wordpress.org/about) v3.9.2 servers with
[lsyncd](https://code.google.com/p/lsyncd/),
[vsftpd](https://security.appspot.com/vsftpd.html#about) and
[Varnish](https://www.varnish-cache.org/about) behind a Cloud Load Balancer.
The database will be hosted on a Linux server with
[MySQL 5.5](http://www.mysql.com/about/).
parameter_groups:
- label: Server Settings
parameters:
- image
- label: Web Server Settings
parameters:
- wp_master_server_flavor
- wp_web_server_count
- wp_web_server_flavor
- label: Database Settings
parameters:
- database_server_flavor
- label: WordPress Settings
parameters:
- domain
- username
- 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:
- kitchen
- chef_version
- child_template
- version
- prefix
- load_balancer_hostname
- wp_web_server_hostnames
- wp_master_server_hostname
- database_server_hostname
parameters:
# Server settings
load_balancer_hostname:
label: Load Balancer Hostname
description: Hostname for the Cloud Load Balancer
type: string
default: WordPress-Load-Balancer
constraints:
- length:
min: 1
max: 64
- allowed_pattern: "^[a-zA-Z][a-zA-Z0-9-]*$"
description: |
Must begin with a letter and contain only alphanumeric characters.
database_server_hostname:
label: Server Name
description: Hostname to use for your WordPress Database Server
type: string
default: WordPress-Database
constraints:
- length:
min: 1
max: 64
- allowed_pattern: "^[a-zA-Z][a-zA-Z0-9-]*$"
description: |
Must begin with a letter and contain only alphanumeric characters.
wp_master_server_hostname:
label: Server Name
description: Hostname to use for your WordPress web-master server.
type: string
default: WordPress-Master
constraints:
- length:
min: 1
max: 64
- allowed_pattern: "^[a-zA-Z][a-zA-Z0-9-]*$"
description: |
Must begin with a letter and contain only alphanumeric characters.
wp_web_server_hostnames:
label: Server Name
description: Hostname to use for all additional WordPress web nodes
type: string
default: WordPress-Web%index%
constraints:
- length:
min: 1
max: 64
- allowed_pattern: "^[a-zA-Z][a-zA-Z0-9%-]*$"
description: |
Must begin with a letter and contain only alphanumeric characters.
wp_web_server_count:
label: Web Server Count
description: Number of web servers to deploy in addition to the web-master
type: number
default: 1
constraints:
- range:
min: 0
max: 7
description: Must be between 0 and 7 servers.
image:
label: Operating System
description: |
Required: 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.
database_server_flavor:
label: Server Size
description: |
Cloud Server size to use for the database server. Sizes refer to the
amount of RAM allocated to the server.
type: string
default: 4 GB General Purpose v1
constraints:
- allowed_values:
- 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
- 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.
wp_master_server_flavor:
label: Master Server Size
description: |
Cloud Server size to use for the web-master node. The size should be at
least one size larger than what you use for the web nodes. This server
handles all admin calls and will ensure files are synced across all
other nodes.
type: string
default: 2 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.
wp_web_server_flavor:
label: Node Server Size
description: |
Cloud Server size to use on all of the additional web nodes.
type: string
default: 2 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.
# WordPress settings
domain:
label: Site Domain
description: Domain to be used with this WordPress site
type: string
default: "example.com"
constraints:
- allowed_pattern: "^[a-zA-Z0-9.-]{1,255}.[a-zA-Z]{2,15}$"
description: Must be a valid domain name
version:
label: WordPress Version
description: Version of WordPress to install
type: string
default: "4.3.1"
constraints:
- allowed_values:
- "4.3.1"
# Optional Apache settings (SSL certs)
# ssl_private_key:
# description: Private SSL key
# type: string
# constraints:
# - allowed_pattern: "^(.){0,5000}$"
# description: "Key values must be under 5,000 characters"
# ssl_certificate:
# description: Public SSL key
# type: string
# constraints:
# - allowed_pattern: "^(.){0,5000}$"
# description: "Certificate values must be under 5,000 characters"
#ssl_intermediate_certs:
# description: Intermediate SSL Certificates
# type: string
# constraints:
# - allowed_pattern: "^(.){0,5000}$"
# description: "Intermediate values must be under 5,000 characters."
# Database and system user configuration
prefix:
label: Wordpress Prefix
description: Prefix to use for database table names.
type: string
default: wp_
constraints:
- allowed_pattern: "^[0-9a-zA-Z$_]{0,10}$"
description: |
Prefix must be shorter than 10 characters, and can only include
letters, numbers, $, and/or underscores.
database_name:
label: Database Name
description: WordPress database name
type: string
default: wordpress
constraints:
- allowed_pattern: "^[0-9a-zA-Z$_]{1,64}$"
description: |
Maximum length of 64 characters, may only contain letters, numbers, and
underscores.
username:
label: Username
description: "Username for system, database, and WordPress logins."
type: string
default: wp_user
constraints:
- allowed_pattern: "^[a-zA-Z0-9 _.@-]{1,16}$"
description: |
Must be shorter than 16 characters and may only contain alphanumeric
characters, ' ', '_', '.', '@', and/or '-'.
## The below parameters are for development purposes. Use the default
## settings for these parameters when attempting to deploy this stack.
# Chef configuration options
kitchen:
label: Kitchen
description: |
URL for the kitchen to use, fetched using git
type: string
default: https://github.com/rackspace-orchestration-templates/wordpress-multi
chef_version:
label: Chef Version
description: Version of chef client to use
type: string
default: 11.16.2
child_template:
label: Child Template
description: |
Location of the child template to use for the WordPress web servers
type: string
default: https://raw.githubusercontent.com/rackspace-orchestration-templates/wordpress-multi/master/wordpress-web-server.yaml
resources:
# Random password generation
database_password:
type: "OS::Heat::RandomString"
properties:
length: 16
sequence: lettersdigits
mysql_root_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
# Random strings for WP salting
wp_auth:
type: "OS::Heat::RandomString"
properties:
length: 32
sequence: hexdigits
wp_logged_in:
type: "OS::Heat::RandomString"
properties:
length: 32
sequence: hexdigits
wp_nonce:
type: "OS::Heat::RandomString"
properties:
length: 32
sequence: hexdigits
wp_secure_auth:
type: "OS::Heat::RandomString"
properties:
length: 32
sequence: hexdigits
# SSH KEYS
sync_key:
type: "OS::Nova::KeyPair"
properties:
name:
str_replace:
template: "%stack_id%-sync"
params:
"%stack_id%": { get_param: "OS::stack_id" }
save_private_key: true
ssh_key:
type: "OS::Nova::KeyPair"
properties:
name: { get_param: "OS::stack_id" }
save_private_key: true
# Server resources
load_balancer:
type: "Rackspace::Cloud::LoadBalancer"
depends_on:
- wp_master_server_setup
- wp_web_servers
properties:
name: { get_param: load_balancer_hostname }
nodes:
- addresses: [ { get_attr: [wp_master_server, networks, private, 0] } ]
port: 80
condition: ENABLED
- addresses: { get_attr: [wp_web_servers, privateIPv4] }
port: 80
condition: ENABLED
healthMonitor:
type: HTTP
delay: 10
timeout: 5
attemptsBeforeDeactivation: 2
path: /
statusRegex: ^[23]0[0-2]$
port: 80
protocol: HTTP
algorithm: ROUND_ROBIN
contentCaching: ENABLED
virtualIps:
- type: PUBLIC
ipVersion: IPV4
metadata:
rax-heat: { get_param: "OS::stack_id" }
database_server:
type: "OS::Nova::Server"
properties:
name: { get_param: database_server_hostname }
flavor: { get_param: database_server_flavor }
image: { get_param: image }
key_name: { get_resource: ssh_key }
metadata:
rax-heat: { get_param: "OS::stack_id" }
cloud_monitoring_config:
type: OS::Heat::SoftwareConfig
properties:
config:
str_replace:
template: |
#!/bin/bash
wget http://meta.packages.cloudmonitoring.rackspace.com/ubuntu-12.04-x86_64/rackspace-cloud-monitoring-meta-stable_1.0_all.deb
dpkg -i rackspace-cloud-monitoring-meta-stable_1.0_all.deb
apt-get update
apt-get install rackspace-monitoring-agent
echo "monitoring_token {{token}}" > /etc/rackspace-monitoring-agent.cfg
service rackspace-monitoring-agent restart
params:
"{{token}}": { get_resource: agent_token }
agent_token:
type: Rackspace::CloudMonitoring::AgentToken
properties:
label: { get_param: "OS::stack_name" }
wp_master_server:
type: "OS::Nova::Server"
properties:
name: { get_param: wp_master_server_hostname }
flavor: { get_param: wp_master_server_flavor }
image: { get_param: image }
key_name: { get_resource: ssh_key }
config_drive: true
user_data_format: RAW
user_data:
get_attr: [ cloud_monitoring_config, config ]
metadata:
rax-heat: { get_param: "OS::stack_id" }
master_cpu_check:
type: Rackspace::CloudMonitoring::Check
properties:
entity: { get_resource: wp_master_server }
type: agent.cpu
label: master_cpu_check
details: {}
metadata:
rax-heat: { get_param: "OS::stack_id" }
stack-name: { get_param: "OS::stack_name" }
period: 30
timeout: 10
master_mem_check:
type: Rackspace::CloudMonitoring::Check
properties:
entity: { get_resource: wp_master_server }
type: agent.memory
label: master_mem_check
details: {}
metadata:
rax-heat: { get_param: "OS::stack_id" }
stack-name: { get_param: "OS::stack_name" }
period: 30
timeout: 10
master_filesystem_check:
type: Rackspace::CloudMonitoring::Check
properties:
entity: { get_resource: wp_master_server }
type: agent.filesystem
label: master_fs_check
details:
target: "/"
metadata:
rax-heat: { get_param: "OS::stack_id" }
stack-name: { get_param: "OS::stack_name" }
period: 30
timeout: 10
wp_web_servers:
type: "OS::Heat::ResourceGroup"
depends_on: database_server
properties:
count: { get_param: wp_web_server_count }
resource_def:
type: { get_param: child_template }
properties:
agent_config: { get_attr: [ cloud_monitoring_config, config ] }
wp_web_server_hostname: { get_param: wp_web_server_hostnames }
image: { get_param: image }
wp_web_server_flavor: { get_param: wp_web_server_flavor }
domain: { get_param: domain }
version: { get_param: version }
# ssl_private_key: { get_param: ssl_private_key }
# ssl_certificate: { get_param: ssl_certificate }
# ssl_intermediate_certs: { get_param: ssl_intermediate_certs }
lsync_pub: { get_attr: [sync_key, public_key]}
varnish_master_backend: { get_attr: [wp_master_server, networks, private, 0] }
prefix: { get_param: prefix }
database_name: { get_param: database_name }
database_host: { get_attr: [database_server, networks, private, 0] }
memcached_host: { get_attr: [database_server, networks, private, 0] }
username: { get_param: username }
database_password: { get_attr: [database_password, value] }
wp_auth: { get_attr: [wp_auth, value] }
wp_logged_in: { get_attr: [wp_logged_in, value] }
wp_nonce: { get_attr: [wp_nonce, value] }
wp_secure_auth: { get_attr: [wp_secure_auth, value] }
ssh_keypair_name: { get_resource: ssh_key }
ssh_private_key: { get_attr: [ssh_key, private_key] }
ssh_public_key: { get_attr: [ssh_key, public_key] }
kitchen: { get_param: kitchen }
chef_version: { get_param: chef_version }
parent_stack_id: { get_param: "OS::stack_id" }
# Chef resources
database_server_setup:
type: "OS::Heat::ChefSolo"
depends_on: database_server
properties:
username: root
private_key: { get_attr: [ssh_key, private_key] }
host: { get_attr: [database_server, accessIPv4] }
kitchen: { get_param: kitchen }
chef_version: { get_param: chef_version }
node:
hollandbackup:
main:
backup_directory: "/var/lib/mysqlbackup"
mysqldump:
user: "root"
host: "localhost"
password: { get_attr: [mysql_root_password, value] }
memcached:
memory: 500
listen: { get_attr: [database_server, networks, private, 0] }
mysql:
bind_address: { get_attr: [database_server, networks, private, 0] }
server_root_password: { get_attr: [mysql_root_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
root_network_acl: [ "10.%" ]
rax:
firewall:
tcp: [22]
mysql:
innodb_buffer_pool_mempercent: 0.6
run_list: ["recipe[apt]",
"recipe[build-essential]",
"recipe[rax-firewall]",
"recipe[mysql::server]",
"recipe[rax-wordpress::memcached-firewall]",
"recipe[memcached]",
"recipe[rax-wordpress::mysql]",
"recipe[rax-wordpress::mysql-firewall]",
"recipe[hollandbackup]",
"recipe[hollandbackup::mysqldump]",
"recipe[hollandbackup::main]",
"recipe[hollandbackup::backupsets]",
"recipe[hollandbackup::cron]"]
wp_master_server_setup:
type: "OS::Heat::ChefSolo"
depends_on:
- database_server_setup
- wp_web_servers
properties:
username: root
private_key: { get_attr: [ssh_key, private_key] }
host: { get_attr: [wp_master_server, accessIPv4] }
kitchen: { get_param: kitchen }
chef_version: { get_param: chef_version }
node:
apache:
listen_ports: [8080]
timeout: 30
serversignature: "Off"
traceenable: "Off"
lsyncd:
interval: 5
monit:
notify_email: 'root@localhost'
mail_format:
from: 'monit@localhost'
mysql:
bind_address: { get_attr: [mysql_root_password, value] }
server_root_password: { get_attr: [mysql_root_password, value] }
sysctl:
values:
fs.inotify.max_user_watches: 1000000
varnish:
version: "3.0"
listen_port: "80"
vsftpd:
ipaddress: ''
write_enable: true
local_umask: "002"
chroot_local_user: false
hide_ids: false
ssl_enable: true
ssl_ciphers: "AES256-SHA"
wordpress:
version: { get_param: version }
server_aliases: [{ get_param: domain }]
dir:
str_replace:
template: "/var/www/vhosts/%domain%"
params:
"%domain%": { get_param: domain }
db:
name: { get_param: database_name }
user: { get_param: username }
pass: { get_attr: [database_password, value] }
host: { get_attr: [database_server, networks, private, 0] }
keys:
auth: { get_attr: [wp_auth, value] }
logged_in: { get_attr: [wp_logged_in, value] }
nonce_key: { get_attr: [wp_nonce, value] }
secure_auth_key: { get_attr: [wp_secure_auth, value] }
rax:
apache:
domain: { get_param: domain }
# ssl_private_key: { get_param: ssl_private_key }
# ssl_certificate: { get_param: ssl_certificate }
# ssl_intermediate_certs: { get_param: ssl_intermediate_certs }
lsyncd:
ssh:
private_key: { get_attr: [sync_key, private_key] }
clients: { get_attr: [wp_web_servers, privateIPv4] }
memcache:
server: { get_attr: [database_server, networks, private, 0] }
varnish:
master_backend: "localhost"
packages:
- php5-imagick
wordpress:
admin_user: { get_param: username }
admin_pass: { get_attr: [database_password, value] }
user:
name: { get_param: username }
group: { get_param: username }
run_list: ["recipe[apt]",
"recipe[build-essential]",
"recipe[mysql::client]",
"recipe[mysql-chef_gem]",
"recipe[rax-wordpress::apache-prep]",
"recipe[sysctl::attribute_driver]",
"recipe[rax-wordpress::x509]",
"recipe[php]",
"recipe[rax-install-packages]",
"recipe[rax-wordpress::wp-database]",
"recipe[wordpress]",
"recipe[rax-wordpress::wp-setup]",
"recipe[rax-wordpress::user]",
"recipe[rax-wordpress::memcache]",
"recipe[lsyncd]",
"recipe[vsftpd]",
"recipe[rax-wordpress::vsftpd]",
"recipe[varnish::repo]",
"recipe[varnish]",
"recipe[rax-wordpress::apache]",
"recipe[rax-wordpress::varnish]",
"recipe[rax-wordpress::varnish-firewall]",
"recipe[rax-wordpress::firewall]",
"recipe[rax-wordpress::vsftpd-firewall]",
"recipe[rax-wordpress::lsyncd]"]
database_server_firewall:
type: "OS::Heat::ChefSolo"
depends_on: wp_master_server_setup
properties:
username: root
private_key: { get_attr: [ssh_key, private_key] }
host: { get_attr: [database_server, accessIPv4] }
kitchen: { get_param: kitchen }
chef_version: { get_param: chef_version }
node:
rax:
memcached:
clients:
- { get_attr: [wp_master_server, networks, private, 0] }
- { get_attr: [wp_web_servers, privateIPv4] }
run_list: ["recipe[rax-wordpress::memcached-firewall]"]
outputs:
private_key:
value: { get_attr: [ssh_key, private_key] }
description: SSH Private IP
load_balancer_ip:
value: { get_attr: [load_balancer, PublicIp] }
description: Load Balancer IP
wordpress_user:
value: { get_param: username }
description: WordPress User
wordpress_password:
value: { get_attr: [database_password, value] }
description: WordPress Password
database_server_ip:
value: { get_attr: [database_server, accessIPv4] }
description: Database Server IP
wordpress_web_master_ip:
value: { get_attr: [wp_master_server, accessIPv4] }
description: Web-Master IP
wordpress_web_ips:
value: { get_attr: [wp_web_servers, accessIPv4] }
description: Web Server IPs
mysql_root_password:
value: { get_attr: [mysql_root_password, value] }
description: MySQL Root Password