forked from aliyun/ros-templates
-
Notifications
You must be signed in to change notification settings - Fork 1
/
wordpress-instance.yml
570 lines (570 loc) · 18.2 KB
/
wordpress-instance.yml
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
ROSTemplateFormatVersion: '2015-09-01'
Description:
en: Create a wordpress instance.
zh-cn: 创建一台ECS实例并部署WordPress。
Parameters:
SelectExistECS:
Type: Boolean
Label:
en: Whether to select an existing instance
zh-cn: 是否选择已有实例
Description:
en: Whether to select an existing Centos7 system instance. The Centos7 system instance must be connected to a public network.
zh-cn: 是否选择已有Centos7系统实例,实例需要开通公网。
Default: false
VpcCidrBlock:
Type: String
Label:
en: VPC CIDR Block
zh-cn: 专有网络网段
Description:
en: 'The IP address range of the VPC in the CIDR Block form; <br>you can use
the following IP address ranges: <br><font color=''green''>[10.0.0.0/8]</font><br><font
color=''green''>[172.16.0.0/12]</font><br><font color=''green''>[192.168.0.0/16]</font>'
zh-cn: 专有网络IP地址段范围,<br>您可以使用以下的IP地址段:<br><font color='green'>[10.0.0.0/8]</font><br><font
color='green'>[172.16.0.0/12]</font><br><font color='green'>[192.168.0.0/16]</font>
Default: 192.168.0.0/16
AllowedValues:
- 192.168.0.0/16
- 172.16.0.0/12
- 10.0.0.0/8
ZoneId:
Type: String
Label:
en: VSwitch Availability Zone
zh-cn: 可用区ID
Description:
en: Availability Zone ID,<br><b>note: <font color='blue'>Before selecting, please confirm that the Availability Zone supports the specification of creating RDS and ECS resources.</font></b>
zh-cn: 可用区ID。<br><b>注: <font color='blue'>选择可用区前请确认该可用区是否支持创建RDS及ECS资源的规格。</font></b>
AssociationProperty: ALIYUN::ECS::Instance:ZoneId
ECSInstanceId:
Type: String
Label:
en: Existing ECS Instance
zh-cn: 已创建ECS实例
Description:
en: Select an ECS instance with the CentOS 7.9 64-bit operating system.
zh-cn: 选择已存在操作系统为CentOS 7.9 64位的ECS实例。
AssociationProperty: ALIYUN::ECS::Instance::InstanceId
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Equals:
- ${SelectExistECS}
- true
Default: ''
VSwitchCidrBlock:
Type: String
Label:
en: VSwitch CIDR Block
zh-cn: 交换机子网网段
Description:
en: CIDR Block of created VSwitch, It must belong to itself VPC CIDR Block.
zh-cn: 交换机网段,必须为专有网络子网段。
Default: 192.168.0.0/24
InstanceType:
Type: String
Label:
en: Instance Type
zh-cn: 实例类型
Description:
en: 'Fill in the specifications that can be used under the VSwitch availability
zone;</b></font><br>general specifications:<font color=''red''><b>ecs.c5.large</b></font><br>note:
a few zones do not support general specifications<br>see detail: <a href=''https://www.alibabacloud.com/help/en/doc-detail/25378.html''
target=''_blank''><b><font color=''blue''>Instance Specification Family.</font></a></b>'
zh-cn: 填写VSwitch可用区下可使用的规格;<br>通用规格:<font color='red'><b>ecs.c5.large</b></font><br>注:可用区可能不支持通用规格<br>规格详见:<a
href='https://help.aliyun.com/document_detail/25378.html' target='_blank'><b><font
color='blue'>实例规格族。</font></a></b>
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: ZoneId
Visible:
Condition:
Fn::Equals:
- ${SelectExistECS}
- false
Default: ecs.c5.large
SystemDiskCategory:
Type: String
Label:
en: System Disk Type
zh-cn: 系统盘类型
Description:
en: '<font color=''blue''><b>Optional values:</b></font><br>[cloud_efficiency: <font color=''green''>Efficient Cloud Disk</font>]<br>[cloud_ssd: <font color=''green''>SSD Cloud Disk</font>]<br>[cloud_essd: <font color=''green''>ESSD Cloud Disk</font>]<br>[cloud: <font color=''green''>Cloud Disk</font>]<br>[ephemeral_ssd: <font color=''green''>Local SSD Cloud Disk</font>]'
zh-cn: '<font color=''blue''><b>可选值:</b></font><br>[cloud_efficiency: <font color=''green''>高效云盘</font>]<br>[cloud_ssd: <font color=''green''>SSD云盘</font>]<br>[cloud_essd: <font color=''green''>ESSD云盘</font>]<br>[cloud: <font color=''green''>普通云盘</font>]<br>[ephemeral_ssd: <font color=''green''>本地SSD盘</font>]'
AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
AssociationPropertyMetadata:
LocaleKey: DiskCategory
InstanceType: ${InstanceType}
ZoneId: ZoneId
Visible:
Condition:
Fn::Equals:
- ${SelectExistECS}
- false
Default: cloud_efficiency
InstancePassword:
Type: String
Label:
en: Instance Password
zh-cn: 实例密码
Description:
en: Server login password, Length 8-30, must contain three(Capital letters,
lowercase letters, numbers, ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol
in).
zh-cn: 服务器登录密码,长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。
ConstraintDescription:
en: Length 8-30, must contain three(Capital letters, lowercase letters, numbers,
()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ Special symbol in).
zh-cn: 长度8-30,必须包含三项(大写字母、小写字母、数字、 ()`~!@#$%^&*_-+=|{}[]:;'<>,.?/ 中的特殊符号)。
AllowedPattern: '[0-9A-Za-z\_\-\&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Equals:
- ${SelectExistECS}
- false
MinLength: 8
MaxLength: 30
NoEcho: true
Default: Admin123
EngineVersion:
Type: String
Label:
en: Engine Version
zh-cn: 数据库版本号
AssociationProperty: ALIYUN::RDS::Engine::EngineVersion
AssociationPropertyMetadata:
Engine: MySQL
Default: "8.0"
DBInstanceClass:
Type: String
Label:
en: Instance Class
zh-cn: 实例规格
AssociationProperty: ALIYUN::RDS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: ${ZoneId}
EngineVersion: ${EngineVersion}
Engine: MySQL
Default: 'rds.mysql.t1.small'
DBInstanceStorage:
Type: Number
Label:
en: Instance Storage
zh-cn: 实例存储
Description:
en: 'Incrementing in every 5G, unit: GB'
zh-cn: 每5G递增,单位:GB
ConstraintDescription:
en: '[5, 2000] Incrementing in every 5G, unit: GB'
zh-cn: '[5, 2000] 每 5G 递增,单位:GB'
MinValue: 5
MaxValue: 2000
Default: 20
DBName:
Type: String
Label:
en: DB Name
zh-cn: 数据库名
Description:
en: Name of WordPress database
zh-cn: WordPress数据库名
ConstraintDescription:
en: Consist of 2 to 64 characters of lowercase letters, underline. Must begin
with a letter and be end with an alphanumeric character.
zh-cn: 由 2 到 64 个小写字母组成,下划线。必须以字母开头,以字母数字字符结尾。
Default: wordpress
MinLength: 2
MaxLength: 64
DBUser:
Type: String
Label:
en: DB Username
zh-cn: 数据库账号
Description:
en: Username of WordPress database
zh-cn: WordPress数据库账号
ConstraintDescription:
en: Consist of 2 to 16 characters of lowercase letters, underline. Must begin
with a letter and be end with an alphanumeric character.
zh-cn: 由 2 到 16 个小写字母组成,下划线。必须以字母开头,以字母数字字符结尾。
Default: wpuser
MinLength: 2
MaxLength: 16
DBPassword:
Type: String
Label:
en: DB Password
zh-cn: 数据库密码
Description:
en: WordPress database password, consisting of letters, numbers, and underline(_),
is 8 to 32 characters long.
zh-cn: WordPress数据库密码,由字母、数字、下划线(_)组成,长度为8~32个字符。
ConstraintDescription:
en: Consisting of letters, numbers, and underline(_),
is 8 to 32 characters long.
zh-cn: 由字母、数字、下划线(_)组成,长度为8~32个字符。
MinLength: 8
MaxLength: 32
NoEcho: true
Conditions:
IsSelectExistECS:
Fn::Equals:
- Ref: SelectExistECS
- false
NotSelectExistECS:
Fn::Equals:
- Ref: SelectExistECS
- true
Resources:
Vpc:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock:
Ref: VpcCidrBlock
VpcName: wordpress_vpc
Metadata:
ALIYUN::ROS::Designer:
id: a42f5f2f-e0b5-4e9c-8aef-dea7ef1c3785
VSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Fn::GetAtt:
- Vpc
- VpcId
CidrBlock:
Ref: VSwitchCidrBlock
Metadata:
ALIYUN::ROS::Designer:
id: f2c86dc8-0554-4d0e-9923-100ad315b695
Database:
Type: ALIYUN::RDS::DBInstance
Properties:
ZoneId:
Ref: ZoneId
VPCId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
DBInstanceClass:
Ref: DBInstanceClass
DBInstanceDescription: DataBase
DBInstanceStorage:
Ref: DBInstanceStorage
DBMappings:
- CharacterSetName: utf8
DBName:
Ref: DBName
Engine: MySQL
EngineVersion:
Ref: EngineVersion
MasterUserPassword:
Ref: DBPassword
MasterUsername:
Ref: DBUser
SecurityIPList: 0.0.0.0/0
AllocatePublicConnection: true
Metadata:
ALIYUN::ROS::Designer:
id: 12a1247f-2409-472a-b877-9c7d51f7b4df
WebServerConditionHandle:
Type: ALIYUN::ROS::WaitConditionHandle
Properties: {}
Metadata:
ALIYUN::ROS::Designer:
id: 4af2a0d0-f515-4cb8-8a2d-1a6443bc41fc
RosWaitCondition:
Type: ALIYUN::ROS::WaitCondition
Properties:
Count: 1
Handle:
Ref: WebServerConditionHandle
Timeout: 3600
Metadata:
ALIYUN::ROS::Designer:
id: fb8cfc4c-e5b0-408e-8f86-e3df7fb05f50
SecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Condition: IsSelectExistECS
Properties:
VpcId:
Ref: Vpc
SecurityGroupName: wordpress_sg
Metadata:
ALIYUN::ROS::Designer:
id: 4740a2b8-d119-4bc8-956d-6b02e2d7aa9f
SecurityGroupIngress:
Type: ALIYUN::ECS::SecurityGroupIngress
Condition: IsSelectExistECS
Properties:
SecurityGroupId:
Ref: SecurityGroup
IpProtocol: all
PortRange: -1/-1
SourceCidrIp: 0.0.0.0/0
Metadata:
ALIYUN::ROS::Designer:
id: 47bec69f-674c-4bed-a162-6b8f94ceed7d
ExistWebServer:
Type: DATASOURCE::ECS::Instances
Condition: NotSelectExistECS
Properties:
InstanceId:
Ref: ECSInstanceId
WebServer:
Type: ALIYUN::ECS::Instance
Condition: IsSelectExistECS
Properties:
VpcId:
Ref: Vpc
VSwitchId:
Ref: VSwitch
SecurityGroupId:
Ref: SecurityGroup
ImageId: centos_7
AllocatePublicIP: true
InstanceType:
Ref: InstanceType
InternetMaxBandwidthOut: 80
IoOptimized: optimized
Password:
Ref: InstancePassword
DependsOn: Database
Metadata:
ALIYUN::ROS::Designer:
id: 8d121091-2248-4d9c-9244-66efdf28856b
Command:
Type: ALIYUN::ECS::Command
Properties:
Timeout: 3600
CommandContent:
Fn::Base64Encode:
Fn::Sub:
- |-
#!/bin/bash
DatabaseUser=${DatabaseUser}
DatabasePwd=${DatabasePwd}
DatabaseName=${DatabaseName}
DatabaseHost=${DatabaseHost}
WebRootPath='/var/www/html'
ApacheIndex='Options Indexes FollowSymLinks'
ApacheIndexReplace='Options Indexes FollowSymLinks'
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
yum install -y unzip zip
yum install -y curl httpd mysql-server php56 php56-php-mysql
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install -y php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-imap.x86_64 php56w-ldap.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 php56w-odbc.x86_64 php56w-process.x86_64 php56w-xml.x86_64 php56w-xmlrpc.x86_64
chkconfig httpd on
# wget http://wordpress.org/latest.tar.gz
# tar -xzvf latest.tar.gz
wget https://ros-template-resources.oss-cn-beijing.aliyuncs.com/WordPress/WordPress.zip
unzip WordPress.zip
mv WordPress-master wordpress
cp wordpress/wp-config-sample.php wordpress/backup-wp-config.php
sed -i "s/database_name_here/$DatabaseName/" wordpress/wp-config-sample.php
sed -i "s/username_here/$DatabaseUser/" wordpress/wp-config-sample.php
sed -i "s/password_here/$DatabasePwd/" wordpress/wp-config-sample.php
sed -i "s/localhost/$DatabaseHost/" wordpress/wp-config-sample.php
mv wordpress/wp-config-sample.php wordpress/wp-config.php
cp -a wordpress/* $WebRootPath
rm -rf wordpress*
service httpd stop
usermod -d $WebRootPath apache &>/dev/null
chown apache:apache -R $WebRootPath
sed -i 's/$ApacheIndex/$ApacheIndexReplace/' /etc/httpd/conf/httpd.conf
service httpd start
${CurlCli} -d '{"data" : "Install nginx."}'
- DatabaseUser:
Ref: DBUser
DatabasePwd:
Ref: DBPassword
DatabaseName:
Ref: DBName
DatabaseHost:
Fn::GetAtt:
- Database
- PublicConnectionString
CurlCli:
Fn::GetAtt:
- WebServerConditionHandle
- CurlCli
Type: RunShellScript
Name:
Ref: ALIYUN::StackId
DependsOn:
- WebServerConditionHandle
Invocation:
Type: ALIYUN::ECS::Invocation
Properties:
InstanceIds:
- Fn::If:
- IsSelectExistECS
- Fn::GetAtt:
- WebServer
- InstanceId
- Ref: ECSInstanceId
CommandId:
Ref: Command
Outputs:
DBInstanceId:
Description: The instance id of created database instance.
Value:
Fn::GetAtt:
- Database
- DBInstanceId
InnerConnectionString:
Description: DB instance connection url by Intranet.
Value:
Fn::GetAtt:
- Database
- InnerConnectionString
InstanceId:
Condition: IsSelectExistECS
Description: The instance id of WebServer instance.
Value:
Fn::GetAtt:
- WebServer
- InstanceId
WordPressUrl:
Description: Wordpress default address.
Value:
Fn::Sub:
- 'http://${IP}'
- IP:
'Fn::If':
- IsSelectExistECS
- 'Fn::GetAtt':
- WebServer
- PublicIp
- 'Fn::Jq':
- First
- >-
if .[0].PublicIpAddress != [] then .[0].PublicIpAddress[0]
else .[0].EipAddress.IpAddress end
- 'Fn::GetAtt':
- ExistWebServer
- Instances
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- VpcCidrBlock
- ZoneId
- VSwitchCidrBlock
Label:
default: VPC
- Parameters:
- SelectExistECS
- ECSInstanceId
- InstanceType
- SystemDiskCategory
- InstancePassword
Label:
default: ECS
- Parameters:
- EngineVersion
- DBInstanceClass
- DBInstanceStorage
- DBName
- DBUser
- DBPassword
Label:
default: RDS
TemplateTags:
- acs:example:网站:基于ECS和RDS创建WordPress环境
ALIYUN::ROS::Designer:
12a1247f-2409-472a-b877-9c7d51f7b4df:
position:
x: 250
y: 130
size:
height: 60
width: 60
z: 2
4740a2b8-d119-4bc8-956d-6b02e2d7aa9f:
position:
x: 350
y: 263
size:
height: 60
width: 60
z: 1
47bec69f-674c-4bed-a162-6b8f94ceed7d:
position:
x: 569
y: 263
size:
height: 60
width: 60
z: 0
4af2a0d0-f515-4cb8-8a2d-1a6443bc41fc:
position:
x: 566
y: 186
size:
height: 60
width: 60
z: 0
78bb2b9f-0209-45c8-83b3-514a01eefb95:
source:
id: 47bec69f-674c-4bed-a162-6b8f94ceed7d
target:
id: 4740a2b8-d119-4bc8-956d-6b02e2d7aa9f
z: 1
7ec2764e-c05a-406e-b0c9-24622e15e941:
source:
id: fb8cfc4c-e5b0-408e-8f86-e3df7fb05f50
target:
id: 4af2a0d0-f515-4cb8-8a2d-1a6443bc41fc
z: 1
8d121091-2248-4d9c-9244-66efdf28856b:
position:
x: 350
y: 130
size:
height: 60
width: 60
z: 2
91d3be94-a57a-4bd4-8470-3af22dc633be:
source:
id: 8d121091-2248-4d9c-9244-66efdf28856b
target:
id: 4740a2b8-d119-4bc8-956d-6b02e2d7aa9f
z: 1
a42f5f2f-e0b5-4e9c-8aef-dea7ef1c3785:
embeds:
- f2c86dc8-0554-4d0e-9923-100ad315b695
- 4740a2b8-d119-4bc8-956d-6b02e2d7aa9f
position:
x: 194
y: 55
size:
height: 311
width: 316
z: 0
f2c86dc8-0554-4d0e-9923-100ad315b695:
embeds:
- 12a1247f-2409-472a-b877-9c7d51f7b4df
- 8d121091-2248-4d9c-9244-66efdf28856b
position:
x: 211
y: 90
size:
height: 151
width: 222
z: 1
fb8cfc4c-e5b0-408e-8f86-e3df7fb05f50:
position:
x: 566
y: 83
size:
height: 60
width: 60
z: 0