forked from aliyun/oos-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathACS::ECS::ElegantRunCommandInSLBVServerGroup.yml
90 lines (90 loc) · 2.41 KB
/
ACS::ECS::ElegantRunCommandInSLBVServerGroup.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
FormatVersion: OOS-2019-06-01
Description: Run the command in the instance of the SLB Verver group.
Parameters:
regionId:
Description: The ID of region.
Type: String
Default: '{{ ACS::RegionId }}'
VServerGroupId:
Description: The ID of ECS vserver group.
Type: String
serverId:
Description: The ID of ECS instance.
Type: String
weight:
Description: The weight of server.
Type: Number
type:
Description: The type of server.
Type: String
port:
Description: The port of server.
Type: Number
commandType:
Description: The type of command.
Type: String
AllowedValues:
- RunBatScript
- RunPowerShellScript
- RunShellScript
Default: RunShellScript
commandContent:
Description: Command content to run in ECS instance.
Type: String
Tasks:
- Name: setServerWeightToZero
Action: 'ACS::ExecuteApi'
Description: Sets server weight to zero.
OnError: recoverServerWeight
Properties:
Service: SLB
API: SetVServerGroupAttribute
Parameters:
RegionId: '{{ regionId }}'
BackendServers:
'Fn::MergeMapToList':
- ServerId:
- '{{ serverId }}'
- Weight:
- 0
- Type:
- '{{ type }}'
- Port:
- '{{ port }}'
VServerGroupId: '{{ VServerGroupId }}'
- Name: runCommand
Action: 'ACS::ECS::RunCommand'
Description: Execute cloud assistant command.
OnError: recoverServerWeight
Properties:
regionId: '{{ regionId }}'
instanceId: '{{ serverId }}'
commandType: '{{ commandType }}'
commandContent: '{{ commandContent }}'
Outputs:
commandOutput:
Type: String
ValueSelector: invocationOutput
- Name: recoverServerWeight
Action: 'ACS::ExecuteApi'
Description: Set the server weight to the original value.
Properties:
Service: SLB
API: SetVServerGroupAttribute
Parameters:
RegionId: '{{ regionId }}'
BackendServers:
'Fn::MergeMapToList':
- ServerId:
- '{{ serverId }}'
- Weight:
- '{{ weight }}'
- Type:
- '{{ type }}'
- Port:
- '{{ port }}'
VServerGroupId: '{{ VServerGroupId }}'
Outputs:
commandOutput:
Type: String
Value: '{{ runCommand.commandOutput }}'