-
Notifications
You must be signed in to change notification settings - Fork 35
/
existing-vpc-single-jenkins.yml
339 lines (338 loc) · 11.4 KB
/
existing-vpc-single-jenkins.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
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 在现有VPC基础上,自动化部署Java 11 & Jenkins 2.384实例,配置公网IP及安全组,通过ROS模版实现基础架构即代码。
en: On top of the existing VPC, automate the deployment of Java 11 & Jenkins 2.384
instances, configure public IP addresses and security groups, and implement infrastructure
as code through ROS (Resource Orchestration Service) templates.
Parameters:
VpcId:
Type: String
Label:
en: Existing VPC Instance ID
zh-cn: 现有VPC的实例ID
Description:
en: Please search the ID starting with (vpc-xxx)from console-Virtual Private
Cloud
zh-cn: 控制台-VPC-专有网络下查询
AssociationProperty: ALIYUN::ECS::VPC::VPCId
VSwitchZoneId:
Type: String
Label:
en: VSwitch Zone ID
zh-cn: 交换机可用区
Description:
en: Availability ID for existing switches
zh-cn: 现有交换机的可用区ID
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
VSwitchId:
Type: String
Label:
en: VSwitch ID
zh-cn: 网络交换机ID
Description:
en: Please search the business VSwitch ID starting with(vsw-xxx)from console-Virtual
Private Cloud-VSwitches
zh-cn: 现有业务网络交换机的实例ID,控制台-VPC-专有网络-交换机下查询
AssociationProperty: ALIYUN::ECS::VSwitch::VSwitchId
AssociationPropertyMetadata:
VpcId: VpcId
ZoneId: VSwitchZoneId
SecurityGroupId:
Type: String
Label:
en: Business Security Group ID
zh-cn: 业务安全组ID
Description:
en: Please search the business security group ID starting with(sg-xxx)from console-ECS-Network
& Security
zh-cn: 现有业务安全组的实例ID,控制台-ECS-网络与安全-安全组下查询
AssociationProperty: ALIYUN::ECS::SecurityGroup::SecurityGroupId
AssociationPropertyMetadata:
VpcId: VpcId
InstanceType:
Type: String
Label:
en: Instance Type
zh-cn: 实例规格
Description:
en: <font color='blue'><b>1.Before selecting the model please confirm that the
current available zone under the model is in stock, some models need to be
reported in advance</b></font>]<br><font color='blue'><b>2.List of optional
models</font>]<br></b></font>[ecs.c5.large <font color='green'>2vCPU 4GiB
Intranet bandwidth1Gbps In-grid sending and receiving packages30MillionPPSS</font>]<br></b>[ecs.c5.xlarge
<font color='green'>4vCPU 8GiB Intranet bandwidth1.5Gbps In-grid sending and
receiving packages50MillionPPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU
16GiB Intranet bandwidth2.5Gbps In-grid sending and receiving packages80MillionPPS</font>]
zh-cn: <font color='blue'><b>1.选择机型前请先确认当前可用区下该机型是否有货,部分机型需要提前报备</b></font><br><font
color='blue'><b>2.可选机型列表</font><br></b></font>[ecs.c5.large <font color='green'>2vCPU
4GiB 内网带宽1Gbps 内网收发包30万PPS</font>]<br></b>[ecs.c5.xlarge <font color='green'>4vCPU
8GiB 内网带宽1.5Gbps 内网收发包50万PPS</font>]<br></b>[ecs.c5.2xlarge <font color='green'>8vCPU
16GiB 内网带宽2.5Gbps 内网收发包80万PPS</font>]
AssociationProperty: ALIYUN::ECS::Instance::InstanceType
AssociationPropertyMetadata:
ZoneId: VSwitchZoneId
InstanceImageId:
Type: String
Label:
en: Image ID
zh-cn: 镜像ID
Description:
en: Image ID,See detail:<b><a href='https://www.alibabacloud.com/help/doc-detail/112977.html'
target='_blank'><font color='blue'>Find the mirror</font></a></b>
zh-cn: 镜像ID, 详见:<b><a href='https://help.aliyun.com/document_detail/112977.html'
target='_blank'><font color='blue'>查找镜像</font></a></b>
AssociationProperty: ALIYUN::ECS::Image::ImageId
AssociationPropertyMetadata:
InstanceType: ${InstanceType}
SupportedImageOwnerAlias:
- system
- self
- others
Default: centos_7_04_64_20G_alibase_201701015.vhd
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\_\-\&:;''<>,=%`~!@#\(\)\$\^\*\+\|\{\}\[\]\.\?\/]+$'
MinLength: 8
MaxLength: 30
NoEcho: true
BindWidth:
Type: Number
Label:
en: Public IP Bandwidth
zh-cn: 公网IP带宽值
Description:
en: 'Public network IP bandwidth,unit: Mbps'
zh-cn: 公网IP带宽值,单位:Mbps
Default: 5
MinValue: 1
MaxValue: 100
DiskCategory:
Type: String
Label:
en: Disk Type
zh-cn: 磁盘类型
AssociationProperty: ALIYUN::ECS::Disk::SystemDiskCategory
AssociationPropertyMetadata:
InstanceType: InstanceType
ZoneId: VSwitchZoneId
DiskSize:
Type: Number
Label:
en: System Disk Space
zh-cn: 系统盘空间
Description:
en: 'The size of the instance system disk, in GiB. Value range: 20 to 500'
zh-cn: 实例系统盘大小,单位为GiB,取值范围:20~500
Default: 40
MinValue: 20
MaxValue: 500
Resources:
EcsInstanceGroup:
Type: ALIYUN::ECS::InstanceGroup
Properties:
ZoneId:
Ref: VSwitchZoneId
VpcId:
Ref: VpcId
VSwitchId:
Ref: VSwitchId
SecurityGroupId:
Ref: SecurityGroupId
ImageId:
Ref: InstanceImageId
AllocatePublicIP: false
HostName:
Fn::Join:
- ''
- - Jenkins
- -[0,3]
InstanceChargeType: PostPaid
InstanceName:
Fn::Join:
- ''
- - Jenkins
- -[0,3]
InstanceType:
Ref: InstanceType
InternetMaxBandwidthIn:
Ref: BindWidth
InternetMaxBandwidthOut:
Ref: BindWidth
IoOptimized: optimized
MaxAmount: 1
Password:
Ref: InstancePassword
SystemDiskCategory:
Ref: DiskCategory
SystemDiskSize:
Ref: DiskSize
UserData:
Fn::Replace:
- ros-notify:
Fn::GetAtt:
- RosWaitConditionHandle
- CurlCli
- Fn::Join:
- ''
- - "#!/bin/sh \n"
- "set -e \n"
- "sleep 10 \n"
- "APP_NAME=\"jenkins\" \n"
- "OSS_NAME=\"ros-template-resources\" \n"
- "OSS_REGION=\"cn-beijing\" \n"
- " \n"
- "PWD_FILE_PATH=\"/tmp/jenkins_init_pwd\" \n"
- "echo \"prepare pwd\" > ${PWD_FILE_PATH} \n"
- " \n"
- "down_resources(){ \n"
- " cd $1 \n"
- " arr=$3 \n"
- " for resource_name in ${arr[*]} \n"
- " do \n"
- ' wget https://${OSS_NAME}.oss-${OSS_REGION}.aliyuncs.com/$2/${resource_name}
'
- " done \n"
- "} \n"
- " \n"
- "install_and_config_java(){ \n"
- " yum install -y java-11-openjdk \n"
- " bash_path=\"/etc/profile\" \n"
- " JAVA_HOME=\"/etc/alternatives/java\" \n"
- " echo \"export JAVA_HOME=${JAVA_HOME}\" >> ${bash_path} \n"
- " echo \"export PATH=${JAVA_HOME}/bin:$PATH\" >> ${bash_path} \n"
- " source ${bash_path} \n"
- "} \n"
- " \n"
- "install_jenkins(){ \n"
- " cd $1 \n"
- " arr=$2 \n"
- " yum -y install glibc.i686 \n"
- " for resource_name in ${arr[*]}; \n"
- " do \n"
- " if [[ ${resource_name} == *.rpm ]]; \n"
- " then \n"
- " rpm -Uvh ${resource_name} && rm -f ${resource_name} \n"
- " fi \n"
- " done \n"
- "} \n"
- " \n"
- "config_jenkins(){ \n"
- " install_and_config_java \n"
- " yum -y install libgcc.i686 --setopt=protected_multilib=false \
\ #resolve jenkins issue \n"
- "} \n"
- " \n"
- "start_jenkins(){ \n"
- " systemctl start jenkins.service \n"
- " systemctl enable jenkins.service \n"
- " cat /var/lib/jenkins/secrets/initialAdminPassword > ${PWD_FILE_PATH}\
\ \n"
- "} \n"
- " \n"
- "run_jenkins(){ \n"
- " resources_name_array=(\"jenkins-2.384-1.1.noarch.rpm\") \n"
- " down_resources $1 \"Jenkins\" \"${resources_name_array[*]}\" \n"
- " install_jenkins $1 \"${resources_name_array[*]}\" \n"
- " config_jenkins \n"
- " start_jenkins \n"
- "} \n"
- " \n"
- "run_jenkins \"/tmp\" \n"
- "InitialAdminPassword=`cat ${PWD_FILE_PATH}` \n"
- "ros-notify -d \"{\\\"Data\\\" : \\\"${InitialAdminPassword}\\\", \\\
\"Status\\\" : \\\"Success\\\"}\" \n"
VpcEip:
Type: ALIYUN::VPC::EIP
Properties:
Bandwidth:
Ref: BindWidth
InternetChargeType: PayByTraffic
EipAssociation:
Type: ALIYUN::VPC::EIPAssociation
Properties:
InstanceId:
Fn::Select:
- '0'
- Fn::GetAtt:
- EcsInstanceGroup
- InstanceIds
AllocationId:
Ref: VpcEip
DependsOn:
- VpcEip
RosWaitConditionHandle:
Type: ALIYUN::ROS::WaitConditionHandle
Properties: {}
RosWaitCondition:
Type: ALIYUN::ROS::WaitCondition
Properties:
Count: 1
Handle:
Ref: RosWaitConditionHandle
Timeout: 1800
Outputs:
EcsInstanceIds:
Value:
Fn::GetAtt:
- EcsInstanceGroup
- InstanceIds
EcsPrivateIp:
Value:
Fn::Select:
- '0'
- Fn::GetAtt:
- EcsInstanceGroup
- PrivateIps
InitialAdminPassword:
Value:
Fn::GetJsonValue:
- '1'
- Fn::GetAtt:
- RosWaitCondition
- Data
JenkinsUrl:
Value:
Fn::Join:
- ''
- - http://
- Fn::GetAtt:
- VpcEip
- EipAddress
- :8080
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- VpcId
- VSwitchZoneId
- VSwitchId
- SecurityGroupId
Label:
default:
en: Infrastructure Configuration
zh-cn: 基础资源配置(必填)
- Parameters:
- InstanceType
- InstanceImageId
- BindWidth
- DiskCategory
- DiskSize
- InstancePassword
Label:
default:
en: Jenkins Configuration
zh-cn: Jenkins 配置(必填)
TemplateTags:
- acs:example:弹性计算:Jenkins单机版(已有VPC)