Tous les produits
Search
Centre de documentation

CloudOps Orchestration Service:ACS-ECS-BulkyRunCommand

Dernière mise à jour :Aug 11, 2026

Nom du modèle

ACS-ECS-BulkyRunCommand : envoi de commandes à distance

Exécuter maintenant

Description du modèle

Ce modèle exécute des commandes Cloud Assistant par lots sur plusieurs instances Elastic Compute Service (ECS). Il est particulièrement adapté aux scénarios de gestion d'applications et d'étiquetage des ressources. Les paramètres obligatoires incluent l'ID de région (regionId), le type de ressource (resourceType) et les instances cibles (targets). Spécifiez également le type de commande (commandType), tel que Shell ou Python, ainsi que le contenu de la commande (commandContent). À l'issue de l'exécution, le modèle renvoie les résultats de l'opération par lot, permettant de vérifier l'état d'exécution des commandes.

Type de modèle

Automatisé

Propriétaire

Alibaba Cloud

Paramètres d'entrée

Paramètre

Description

Type

Obligatoire

Valeur par défaut

Limite

targets

Instance cible

Json

Oui

commandContent

Contenu de la commande.

String

Oui

La taille de la commande ne peut pas dépasser 16 384 octets.

regionId

ID de région.

String

Non

{{ ACS::RegionId }}

resourceType

Type de ressource.

String

Non

ALIYUN::ECS::Instance

commandType

Type de commande.

String

Non

RunShellScript

workingDir

Répertoire d'exécution de la commande.

String

Non

""

timeout

Délai d'expiration en secondes.

Number

Non

600

enableParameter

Indique si la commande contient des paramètres chiffrés ou personnalisés.

Boolean

Non

False

username

Nom d'utilisateur du compte utilisé pour exécuter la commande.

String

Non

""

windowsPasswordName

Mot de passe du compte utilisé pour exécuter la commande sur les instances Windows.

String

Non

""

rateControl

Concurrence d'exécution des tâches

Json

Non

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

OOSAssumeRole

Rôle RAM endossé par OOS.

String

Non

""

Paramètres de sortie

Paramètre

Description

Type

commandOutputs

List

Stratégie d'autorisation requise pour exécuter le modèle

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

Détails

Détails de ACS-ECS-BulkyRunCommand

Contenu du modèle

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