Template name
ACS-ECS-BulkyRunCommandInSLBVServerGroup
Template description
Runs a command on multiple Elastic Compute Service (ECS) instances in a vServer group of a Server Load Balancer (SLB) instance at a time.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
VServerGroupId | The ID of the vServer group. | String | Yes | ||
commandType | The type of the Cloud Assistant command. | String | No | RunShellScript | |
commandContent | The Cloud Assistant command to be run on the ECS instances. | String | No | echo hello | |
rateControl | The rate control settings. | Json | No | {'Mode': 'Concurrency', 'MaxErrors': '0', 'Concurrency': 1} | |
OOSAssumeRole | The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS). | String | No | "" |
Output parameters
Parameter | Description | Type |
commandOutputs | List |
Permission policy that is required to execute the template
{
"Version": "1",
"Statement": [
{
"Action": [
"slb:DescribeVServerGroupAttribute",
"slb:SetVServerGroupAttribute"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
References
For more information, see ACS-ECS-BulkyRunCommandInSLBVServerGroup.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: Bulky run command on ECS instances of VServer group
zh-cn: the description in Chinese
name-en: ACS-ECS-BulkyRunCommandInSLBVServerGroup
name-zh-cn: the description in Chinese
categories:
- slb_management
Parameters:
VServerGroupId:
Label:
en: VServerGroupId
zh-cn: the description in Chinese
Type: String
commandType:
Label:
en: CommandType
zh-cn: the description in Chinese
Type: String
AllowedValues:
- RunBatScript
- RunPowerShellScript
- RunShellScript
Default: RunShellScript
commandContent:
Label:
en: CommandContent
zh-cn: the description in Chinese
Type: String
AssociationProperty: Code
Default: echo hello
rateControl:
Label:
en: RateControl
zh-cn: the description in Chinese
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 1
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: the description in Chinese
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: describeVServerGroupAttribute
Action: ACS::ExecuteApi
Description:
en: Views vserver group attribute
zh-cn: the description in Chinese
Properties:
Service: SLB
API: DescribeVServerGroupAttribute
Parameters:
VServerGroupId: '{{ VServerGroupId }}'
Outputs:
BackendServers:
Type: List
ValueSelector: BackendServers.BackendServer[]
- Name: runCommand
Action: ACS::ECS::ElegantRunCommandInSLBVServerGroup
Description:
en: Execute cloud assistant command
zh-cn: the description in Chinese
Properties:
VServerGroupId: '{{ VServerGroupId }}'
commandContent: '{{ commandContent }}'
commandType: '{{ commandType }}'
serverId:
'Fn::Select':
- ServerId
- '{{ ACS::TaskLoopItem }}'
weight:
'Fn::Select':
- Weight
- '{{ ACS::TaskLoopItem }}'
type:
'Fn::Select':
- Type
- '{{ ACS::TaskLoopItem }}'
port:
'Fn::Select':
- Port
- '{{ ACS::TaskLoopItem }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ describeVServerGroupAttribute.BackendServers }}'
Outputs:
commandOutputs:
AggregateType: Fn::ListJoin
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: commandOutput
Outputs:
commandOutputs:
Type: List
Value: '{{ runCommand.commandOutputs }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- VServerGroupId
- commandType
- commandContent
Label:
default:
zh-cn: the description in Chinese
en: Configure Parameters
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: the description in Chinese
en: Control