Template name
ACS-ECS-BulkyRunCommand
Template description
Runs a Cloud Assistant command on multiple Elastic Compute Service (ECS) instances at a time.
Template type
Automated
Owner
Alibaba Cloud
Input parameters
Parameter | Description | Type | Required | Default value | Limit |
targets | The ECS instances on which you want to run a Cloud Assistant command. | Json | Yes | ||
commandContent | The command content. | String | Yes | The command can be up to 16,384 bytes in length. | |
regionId | The region ID. | String | No | {{ ACS::RegionId }} | |
resourceType | The resource type. | String | No | ALIYUN::ECS::Instance | |
commandType | The command type. | String | No | RunShellScript | |
workingDir | The directory in which the command is run. | String | No | "" | |
timeout | The timeout period. | Number | No | 600 | |
enableParameter | Specifies whether the command contains encryption parameters or custom parameters. | Boolean | No | False | |
username | The username of the account that is used to run the command. | String | No | "" | |
windowsPasswordName | The password of the account that is used to run the command on the Windows instance. | String | No | "" | |
rateControl | The rate control settings. | Json | No | {'Mode': 'Concurrency', 'MaxErrors': '0', 'Concurrency': 10} | |
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": [
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:DescribeManagedInstances",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
References
For more information, see ACS-ECS-BulkyRunCommand.yml at GitHub.
Template content
FormatVersion: OOS-2019-06-01
Description:
en: Bulky run command on ECS instances
zh-cn: the description in Chinese
name-en: Run Command
name-zh-cn: the description in Chinese
categories:
- run_command
- application_manage
- computenest
Parameters:
regionId:
Type: String
Label:
en: RegionId
zh-cn: the description in Chinese
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
resourceType:
Type: String
Label:
en: ResourceType
zh-cn: the description in Chinese
AssociationPropertyMetadata:
LocaleKey: TargetResourceType
AllowedValues:
- ALIYUN::ECS::Instance
- ALIYUN::ECS::ManagedInstance
Default: ALIYUN::ECS::Instance
targets:
Type: Json
Label:
en: TargetInstance
zh-cn: the description in Chinese
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: resourceType
RegionId: regionId
Status: Running
commandType:
Label:
en: CommandType
zh-cn: the description in Chinese
AssociationPropertyMetadata:
LocaleKey: ECSCommandType
Type: String
AllowedValues:
- RunShellScript
- RunPythonScript
- RunPerlScript
- RunBatScript
- RunPowerShellScript
Default: RunShellScript
commandContent:
Label:
en: CommandContent
zh-cn: the description in Chinese
Type: String
MaxLength: 16384
AssociationProperty: ALIYUN::OOS::Command::CommandContent
AssociationPropertyMetadata:
CommandType: ${commandType}
workingDir:
Description:
en: 'Linux instances: under the home directory of the administrator (root user): /root.Windows instances: under the directory where the process of the Cloud Assistant client is located, such asC:\Windows\System32. Please ensure you input the correct directory.'
zh-cn: the description in Chinese '
Label:
en: WorkingDir
zh-cn: the description in Chinese
Type: String
Default: ''
AssociationPropertyMetadata:
Value:
- Condition:
Fn::Or:
- Fn::Equals:
- ${commandType}
- RunShellScript
- Fn::Equals:
- ${commandType}
- RunPythonScript
- Fn::Equals:
- ${commandType}
- RunPerlScript
Value: /root
- Condition:
Fn::Or:
- Fn::Equals:
- ${commandType}
- RunBatScript
- Fn::Equals:
- ${commandType}
- RunPowerShellScript
Value: C:\\Windows\\System32
timeout:
Label:
en: Timeout
zh-cn: the description in Chinese
Type: Number
Default: 600
enableParameter:
Label:
en: EnableParameter
zh-cn: the description in Chinese
Type: Boolean
Default: false
username:
Description:
en: The username that is used to run the command on the ECS instance, length must not exceed 255 characters. Linux system ECS instance, the default is root. Windows system ECS instance, the default is System. Please ensure you input the correct username. <a href="https://www.alibabacloud.com/help/doc-detail/203771.html" target="_blank">See more</a>
zh-cn: the description in Chinese
Label:
en: Username
zh-cn: the description in Chinese
Type: String
Default: ''
windowsPasswordName:
Label:
en: WindowsPasswordName
zh-cn: the description in Chinese
Type: String
Default: ''
AssociationProperty: ALIYUN::OOS::SecretParameter::Value
AssociationPropertyMetadata:
Visible:
Condition:
Fn::Or:
- Fn::Equals:
- ${commandType}
- RunBatScript
- Fn::Equals:
- ${commandType}
- RunPowerShellScript
rateControl:
Label:
en: RateControl
zh-cn: the description in Chinese
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: the description in Chinese
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
Description:
en: Views the ECS instances
zh-cn: the description in Chinese
Action: ACS::SelectTargets
Properties:
ResourceType: '{{ resourceType }}'
RegionId: '{{ regionId }}'
Filters:
- '{{ targets }}'
Outputs:
instanceIds:
Type: List
ValueSelector: Instances.Instance[].InstanceId
- Name: runCommand
Action: ACS::ECS::RunCommand
Description:
en: Execute cloud assistant command
zh-cn: the description in Chinese
Properties:
regionId: '{{ regionId }}'
commandContent: '{{ commandContent }}'
instanceId: '{{ ACS::TaskLoopItem }}'
commandType: '{{ commandType }}'
workingDir: '{{ workingDir }}'
timeout: '{{ timeout }}'
enableParameter: '{{ enableParameter }}'
username: '{{ username }}'
windowsPasswordName: '{{ windowsPasswordName }}'
Loop:
RateControl: '{{ rateControl }}'
Items: '{{ getInstance.instanceIds }}'
Outputs:
commandOutputs:
AggregateType: Fn::ListJoin
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: invocationOutput
Outputs:
commandOutputs:
Type: List
Value: '{{ runCommand.commandOutputs }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- commandType
- commandContent
- workingDir
- timeout
- enableParameter
- username
- windowsPasswordName
Label:
default:
zh-cn: the description in Chinese
en: run command options
- Parameters:
- regionId
- resourceType
- targets
Label:
default:
zh-cn: the description in Chinese
en: Select Ecs Instances
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: the description in Chinese
en: Control Options