全部产品
Search
文档中心

CloudOps Orchestration Service:ACS-ECS-BulkyRunCommand

更新时间:Dec 21, 2025

Nama Template

ACS-ECS-BulkyRunCommand: Kirim perintah remote

Jalankan Sekarang

Deskripsi Template

Jalankan perintah Cloud Assistant pada beberapa instance Elastic Compute Service (ECS) secara batch. Template ini dirancang untuk skenario yang memerlukan pengelolaan banyak instance ECS sekaligus, seperti manajemen aplikasi dan pemberian tag pada resource. Saat mengonfigurasi template, Anda harus menyediakan parameter yang diperlukan, termasuk ID wilayah (regionId), tipe resource (resourceType), dan instance target (targets). Anda juga menentukan tipe perintah (commandType), seperti Shell atau Python, serta isi perintah (commandContent). Setelah template dijalankan, output dari operasi batch tersebut akan dikembalikan, yang dapat digunakan untuk memverifikasi status eksekusi perintah.

Tipe Template

Otomatis

Pemilik

Alibaba Cloud

Parameter masukan

Parameter

Deskripsi

Tipe

Diperlukan

Nilai Default

Batasan

targets

Instans target

Json

Ya

commandContent

Isi perintah.

String

Ya

Perintah dapat memiliki panjang hingga 16.384 byte.

regionId

ID wilayah.

String

Tidak

{{ ACS::RegionId }}

resourceType

Jenis sumber daya.

String

Tidak

ALIYUN::ECS::Instance

commandType

Jenis perintah.

String

Tidak

RunShellScript

workingDir

Direktori tempat perintah dijalankan.

String

Tidak

""

timeout

Periode timeout dalam detik.

Number

Tidak

600

enableParameter

Menentukan apakah perintah berisi parameter enkripsi atau parameter kustom.

Boolean

Tidak

False

username

Nama pengguna akun yang digunakan untuk menjalankan perintah.

String

Tidak

""

windowsPasswordName

Kata sandi akun yang digunakan untuk menjalankan perintah pada instance Windows.

String

Tidak

""

rateControl

Konkurensi eksekusi tugas

Json

Tidak

{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10}

OOSAssumeRole

Peran Resource Access Management (RAM) yang diasumsikan oleh CloudOps Orchestration Service (OOS).

String

Tidak

""

Parameter Output

Parameter

Deskripsi

Tipe

commandOutputs

List

Kebijakan Izin yang Diperlukan untuk Menjalankan Template

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeInstances",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:DescribeManagedInstances",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oos:GetApplicationGroup"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Detail

Detail ACS-ECS-BulkyRunCommand

Isi Template

FormatVersion: OOS-2019-06-01
Description:
  en: 'Runs Cloud Assistant commands on multiple Elastic Compute Service (ECS) instances in batches. This template is for scenarios that require managing many ECS instances at once, such as for application management and resource tagging. When you configure the template, you must provide required parameters. These include the region ID (regionId), the resource type (resourceType), and the target instances (targets). You also specify the command type (commandType), such as Shell or Python, and the command content (commandContent). After the template runs, it returns the output of the batch operation. You can use the output to verify the command execution status.'
  zh-cn: the description in Chinese
  name-en: Run Command
  name-zh-cn: the description in Chinese
  categories:
    - run_command
    - application_manage
    - computenest
    - tag_operate_resource
Parameters:
  regionId:
    Type: String
    Label:
      en: Region ID
      zh-cn: the description in Chinese
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  resourceType:
    Type: String
    Label:
      en: Resource type
      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: Target instance
      zh-cn: the description in Chinese
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: resourceType
      RegionId: regionId
      Status: Running
  commandType:
    Label:
      en: Command type
      zh-cn: the description in Chinese
    AssociationPropertyMetadata:
      LocaleKey: ECSCommandType
    Type: String
    AllowedValues:
      - RunShellScript
      - RunPythonScript
      - RunPerlScript
      - RunBatScript
      - RunPowerShellScript
    Default: RunShellScript
  commandContent:
    Label:
      en: Command content
      zh-cn: the description in Chinese
    Type: String
    MaxLength: 16384
    AssociationProperty: ALIYUN::OOS::Command::CommandContent
    AssociationPropertyMetadata:
      CommandType: ${commandType}
  workingDir:
    Description:
      en: 'For Linux instances, the default is the home directory of the administrator (root), which is /root. For Windows instances, the default is the directory where the Cloud Assistant client process is located, such as C:\Windows\System32. Ensure that the directory you enter is correct.'
      zh-cn: the description in Chinese
    Label:
      en: Working directory
      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 (s)
      zh-cn: the description in Chinese
    Type: Number
    Default: 600
  enableParameter:
    Label:
      en: Enable parameter
      zh-cn: the description in Chinese
    Type: Boolean
    Default: false
  username:
    Description:
      en: The username to run the command on the ECS instance. The username can be up to 255 characters long. For Linux instances, the command is run as the root user by default. For Windows instances, the command is run as the System user by default. Ensure that the username you enter is correct. <a href="https://www.alibabacloud.com/help/doc-detail/203771.html" target="_blank">Learn more</a>
      zh-cn: the description in Chinese
    Label:
      en: Username
      zh-cn: the description in Chinese
    Type: String
    Default: ''
  windowsPasswordName:
    Label:
      en: Password name for Windows user
      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: Rate control
      zh-cn: the description in Chinese
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: RAM role assumed by OOS
      zh-cn: the description in Chinese
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Gets 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: Runs the 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: Command execution options
      - Parameters:
          - regionId
          - resourceType
          - targets
        Label:
          default:
            zh-cn: the description in Chinese
            en: Select instances
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: the description in Chinese
            en: Advanced options