-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathACS-ECS-RepairWindowsBlueScreenIssue.yml
300 lines (297 loc) · 8.43 KB
/
ACS-ECS-RepairWindowsBlueScreenIssue.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
FormatVersion: OOS-2019-06-01
Description:
en: Solutions to Repair Windows System Blue Screen Issues
zh-cn: 修复Windows系统蓝屏问题解决方案
name-en: ACS-ECS-RepairWindowsBlueScreenIssue
name-zh-cn: 修复Windows系统蓝屏问题
Parameters:
regionId:
Type: String
Label:
en: RegionId
zh-cn: 地域ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
instanceId:
Type: String
AssociationProperty: ALIYUN::ECS::Instance::InstanceId
AssociationPropertyMetadata:
RegionId: regionId
Label:
en: InstanceId
zh-cn: 实例Id
password:
Type: String
AssociationProperty: ALIYUN::ECS::Instance::Password
Label:
en: ECS Instance Password
zh-cn: 实例密码
NoEcho: true
RamRole: ''
Tasks:
- Name: getZoneId
Action: ACS::ExecuteApi
Description:
en: Get zoneId of ECS instance
zh-cn: 获取ECS实例可用区
Properties:
Service: ecs
API: DescribeInstances
Parameters:
RegionId: '{{ regionId }}'
InstanceIds:
- '{{ instanceId }}'
Outputs:
zoneId:
Type: String
ValueSelector: .Instances.Instance[].ZoneId
instanceType:
Type: String
ValueSelector: .Instances.Instance[].InstanceType
- Name: createStack
Action: ACS::ExecuteAPI
Description:
en: Create a resource stack of VPC
zh-cn: 创建VPC资源栈
Properties:
Service: ROS
API: CreateStack
Parameters:
RegionId: '{{ regionId }}'
StackName: OOS-{{ACS::ExecutionId}}
TimeoutInMinutes: 10
DisableRollback: false
Parameters:
- ParameterKey: ZoneId
ParameterValue: '{{ getZoneId.zoneId }}'
- ParameterKey: VpcCidrBlock
ParameterValue: 192.168.0.0/16
- ParameterKey: VSwitchCidrBlock
ParameterValue: 192.168.1.0/24
TemplateBody: |
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
ZoneId:
Type: String
VpcCidrBlock:
Type: String
VSwitchCidrBlock:
Type: String
Resources:
EcsVpc:
Type: ALIYUN::ECS::VPC
Properties:
CidrBlock:
Ref: VpcCidrBlock
VpcName:
Ref: ALIYUN::StackName
EcsVSwitch:
Type: ALIYUN::ECS::VSwitch
Properties:
ZoneId:
Ref: ZoneId
VpcId:
Ref: EcsVpc
CidrBlock:
Ref: VSwitchCidrBlock
EcsSecurityGroup:
Type: ALIYUN::ECS::SecurityGroup
Properties:
VpcId:
Ref: EcsVpc
Outputs:
SecurityGroupId:
Value:
Ref: EcsSecurityGroup
VSwitchId:
Value:
Ref: EcsVSwitch
Outputs:
StackId:
Type: String
ValueSelector: StackId
- Name: untilStackReady
Action: ACS::WaitFor
Description:
en: Wait for the stack status CREATE_COMPLETE
zh-cn: 等待资源栈至创建成功状态
OnError: deleteStack
Retries: 10
DelayType: Exponential
Delay: 2
BackOff: 2
Properties:
Service: ROS
API: GetStack
Parameters:
RegionId: '{{ regionId }}'
StackId: '{{createStack.StackId}}'
DesiredValues:
- CREATE_COMPLETE
StopRetryValues:
- CREATE_FAILED
- CHECK_FAILED
- ROLLBACK_FAILED
- ROLLBACK_COMPLETE
- CREATE_ROLLBACK_COMPLETE
PropertySelector: Status
NotDesiredValues: []
Outputs:
securityGroupId:
Type: String
ValueSelector: Outputs[0].OutputValue
vSwitchId:
Type: String
ValueSelector: Outputs[1].OutputValue
- Name: runInstances
Action: ACS::ECS::RunInstances
Description:
en: Create a temporary ECS instance
zh-cn: 创建临时ECS实例
OnError: deleteStack
Properties:
regionId: '{{ regionId }}'
imageId: wincore_2022_x64_dtc_zh-cn_40G_alibase_20240617.vhd
instanceType: '{{ getZoneId.instanceType }}'
securityGroupId: '{{ untilStackReady.securityGroupId }}'
vSwitchId: '{{ untilStackReady.vSwitchId }}'
systemDiskCategory: cloud_essd
systemDiskSize: '40'
internetMaxBandwidthIn: 0
internetMaxBandwidthOut: 0
amount: 1
Outputs:
instanceId:
Type: String
ValueSelector: instanceIds[0]
- Name: StopInstance
Action: ACS::ECS::StopInstance
Description:
en: Stop ECS instance pending repair.
zh-cn: 停止待修复ECS实例
OnError: deleteInstance
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ instanceId }}'
forceStop: true
- Name: getDiskId
Action: ACS::ExecuteApi
Description:
en: Get system disk ID of the ECS instance pending repair.
zh-cn: 获取待修复ECS实例系统盘Id
Properties:
Service: ecs
API: DescribeDisks
Parameters:
RegionId: '{{ regionId }}'
InstanceId: '{{ instanceId }}'
DiskType: system
Outputs:
diskId:
Type: String
ValueSelector: .Disks.Disk[].DiskId
- Name: detachSystemDisk
Description:
en: Detach system disk of the ECS instance pending repair.
zh-cn: 卸载待修复ECS实例系统盘
Action: ACS::ECS::DetachDisk
OnError: deleteInstance
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ instanceId }}'
diskId: '{{ getDiskId.diskId }}'
- Name: attachDiskToTempInstance
Action: ACS::ECS::AttachDisk
Description:
en: Attach disk to a temporary ECS instance.
zh-cn: 将磁盘挂载到临时ECS实例
OnError: deleteInstance
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ runInstances.instanceId }}'
diskId: '{{ getDiskId.diskId }}'
- Name: waitForAWhile
Description:
en: Wait for ready
zh-cn: 等待状态就绪
Action: ACS::Sleep
Properties:
Duration: PT4M
- Name: runCommand
Action: ACS::ECS::RunCommand
Description:
en: Run the repair command.
zh-cn: 运行修复命令
Properties:
regionId: '{{ regionId }}'
commandType: RunPowerShellScript
instanceId: '{{ runInstances.instanceId }}'
commandContent: |-
$disks = Get-Disk
$disks | ForEach-Object {
if ($_.IsOffline) {
Set-Disk -Number $_.Number -IsOffline $false
}
if ($_.IsReadOnly) {
Set-Disk -Number $_.Number -IsReadOnly $false
}
}
# Rename driver dir
$driverDir = "D:\windows\system32\drivers\CrowdStrike"
if (!(Test-Path $driverDir)) {
Write-Host "driver path not found"
exit 1
}
Rename-Item -Path $driverDir -NewName ($driverDir + ".bak")
- Name: detachDisk
Action: ACS::ECS::DetachDisk
Description:
en: Detach disk from the temporary instance.
zh-cn: 从临时实例卸载磁盘
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ runInstances.instanceId }}'
diskId: '{{ getDiskId.diskId }}'
- Name: attachDiskToOriginalInstance
Action: ACS::ECS::AttachDisk
Description:
en: Attach disk to the original instance.
zh-cn: 将磁盘挂载回源实例
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ instanceId }}'
diskId: '{{ getDiskId.diskId }}'
bootable: true
password: '{{ password }}'
- Name: startInstance
Action: ACS::ECS::StartInstance
Description:
en: Start original instance.
zh-cn: 启动源实例
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ instanceId }}'
- Name: deleteInstance
Action: ACS::ExecuteAPI
Description:
en: Delete the temporary instance.
zh-cn: 删除临时实例
Properties:
Service: ECS
API: DeleteInstance
Risk: Normal
Parameters:
RegionId: '{{ regionId }}'
InstanceId: '{{ runInstances.instanceId }}'
Force: true
- Name: deleteStack
Action: ACS::ExecuteApi
Description:
en: Delete the stack of VPC
zh-cn: 删除VPC资源栈
Properties:
Service: ROS
API: DeleteStack
Parameters:
RegionId: '{{ regionId }}'
StackId: '{{ createStack.StackId }}'