模板名称
ACS-ECS-BulkyRunCommand 发送远程命令
模板描述
批量在多台ECS实例上运行云助手命令,适用于需要同时管理多台ECS实例的场景,如应用程序管理和资源标记操作等。在配置过程中,用户需要提供以下必填参数信息:地域ID(regionId):用于指定需要执行命令的目标ECS实例所在的区域,资源类型(resourceType):用于确定目标ECS实例的类型(如ECS实例或受管实例),目标实例(targets):用于选择要操作的具体实例列表。参数还包括命令类型(commandType):指定要执行的命令类型(如Shell脚本、Python脚本等),以及命令内容(commandContent):具体的命令或脚本内容。模板在执行后会返回批量操作的输出结果,方便用户验证命令执行的状态。
模板类型
自动化
所有者
Alibaba Cloud
输入参数
参数名称 | 描述 | 类型 | 是否必填 | 默认值 | 约束 |
targets | 目标实例 | Json | 是 | ||
commandContent | 命令内容 | String | 是 | 最大长度 : 16384 | |
regionId | 地域ID | String | 否 | {{ ACS::RegionId }} | |
resourceType | 资源类型 | String | 否 | ALIYUN::ECS::Instance | |
commandType | 命令类型 | String | 否 | RunShellScript | |
workingDir | 运行目录 | String | 否 | “” | |
timeout | 超时时间 | Number | 否 | 600 | |
enableParameter | 命令中是否包含加密参数或自定义参数 | Boolean | 否 | False | |
username | 执行命令的用户名称 | String | 否 | “” | |
windowsPasswordName | 在Windows实例中执行命令的用户的密码名称 | String | 否 | “” | |
rateControl | 任务执行的并发比率 | Json | 否 | {‘Mode’: ‘Concurrency’, ‘MaxErrors’: 0, ‘Concurrency’: 10} | |
OOSAssumeRole | OOS扮演的RAM角色 | String | 否 | “” |
输出参数
参数名称 | 描述 | 类型 |
commandOutputs | List |
执行此模板需要的权限策略
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:DescribeManagedInstances",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
详情
模板内容
FormatVersion: OOS-2019-06-01
Description:
en: 'Bulky run commands on multiple ECS instances, applicable to scenarios that require managing multiple ECS instances simultaneously, such as application management and resource tagging operations. During configuration, users need to provide the following required parameter information: Region ID (regionId), which specifies the region of the target ECS instances where the commands will be executed, Resource Type (resourceType), to determine the type of target ECS instances (e.g., ECS instance or managed instance), and Target Instances (targets), to select the specific instances to be operated on. Other parameters include Command Type (commandType), which specifies the type of command to be executed (e.g., Shell script, Python script, etc.), and Command Content (commandContent), which is the actual command or script. Upon execution, the template provides the output results of the bulk operation, enabling users to verify the status of the command executions.'
zh-cn: 批量在多台ECS实例上运行云助手命令,适用于需要同时管理多台ECS实例的场景,如应用程序管理和资源标记操作等。在配置过程中,用户需要提供以下必填参数信息:地域ID(regionId):用于指定需要执行命令的目标ECS实例所在的区域,资源类型(resourceType):用于确定目标ECS实例的类型(如ECS实例或受管实例),目标实例(targets):用于选择要操作的具体实例列表。参数还包括命令类型(commandType):指定要执行的命令类型(如Shell脚本、Python脚本等),以及命令内容(commandContent):具体的命令或脚本内容。模板在执行后会返回批量操作的输出结果,方便用户验证命令执行的状态。
name-en: Run Command
name-zh-cn: 发送远程命令
categories:
- run_command
- application_manage
- computenest
Parameters:
regionId:
Type: String
Label:
en: RegionId
zh-cn: 地域ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
resourceType:
Type: String
Label:
en: ResourceType
zh-cn: 资源类型
AssociationPropertyMetadata:
LocaleKey: TargetResourceType
AllowedValues:
- ALIYUN::ECS::Instance
- ALIYUN::ECS::ManagedInstance
Default: ALIYUN::ECS::Instance
targets:
Type: Json
Label:
en: TargetInstance
zh-cn: 目标实例
AssociationProperty: Targets
AssociationPropertyMetadata:
ResourceType: resourceType
RegionId: regionId
Status: Running
commandType:
Label:
en: CommandType
zh-cn: 命令类型
AssociationPropertyMetadata:
LocaleKey: ECSCommandType
Type: String
AllowedValues:
- RunShellScript
- RunPythonScript
- RunPerlScript
- RunBatScript
- RunPowerShellScript
Default: RunShellScript
commandContent:
Label:
en: CommandContent
zh-cn: 命令内容
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: Linux系统实例默认在管理员(root用户)的home目录下,即/root。Windows系统实例默认在云助手客户端进程所在目录,例如C:\Windows\System32。请确保您输入的目录是正确的。'
Label:
en: WorkingDir
zh-cn: 运行目录
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: 超时时间
Type: Number
Default: 600
enableParameter:
Label:
en: EnableParameter
zh-cn: 命令中是否包含加密参数或自定义参数
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: 在ECS实例中执行命令的用户名称,长度不得超过255个字符。Linux系统的实例,默认以root用户执行命令。Windows系统的实例,默认以System用户执行命令。请确保您输入的用户名是正确的。<a href="https://www.alibabacloud.com/help/doc-detail/203771.html" target="_blank">了解更多</a>
Label:
en: Username
zh-cn: 执行命令的用户名称
Type: String
Default: ''
windowsPasswordName:
Label:
en: WindowsPasswordName
zh-cn: 在Windows实例中执行命令的用户的密码名称
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: 任务执行的并发比率
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: OOS扮演的RAM角色
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: getInstance
Description:
en: Views the ECS instances
zh-cn: 获取ECS实例
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: 执行云助手命令
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: 执行命令选型
en: run command options
- Parameters:
- regionId
- resourceType
- targets
Label:
default:
zh-cn: 选择实例
en: Select Ecs Instances
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: 高级选项
en: Control Options