すべてのプロダクト
Search
ドキュメントセンター

CloudOps Orchestration Service:ACS-ECS-BulkyRunCommand

最終更新日:Dec 21, 2025

テンプレート名

ACS-ECS-BulkyRunCommand:リモートコマンドの送信

今すぐ実行

テンプレートの説明

複数の Elastic Compute Service (ECS) インスタンスでクラウドアシスタントコマンドをバッチ実行します。このテンプレートは、アプリケーション管理やリソースのタグ付けなど、多数の ECS インスタンスを同時に管理する必要があるシナリオ向けに設計されています。テンプレートを設定する際には、リージョン ID (`regionId`)、リソースタイプ (`resourceType`)、ターゲットインスタンス (`targets`) などの必須パラメーターを指定する必要があります。また、コマンドタイプ (`commandType`) (Shell や Python など) とコマンド内容 (`commandContent`) も指定します。テンプレートの実行後、バッチ操作の出力が返され、これを使用してコマンドの実行ステータスを確認できます。

テンプレートタイプ

自動化

所有者

Alibaba Cloud

入力パラメーター

パラメーター

説明

タイプ

必須

デフォルト値

制限

targets

ターゲットインスタンス

Json

はい

commandContent

コマンドの内容。

String

はい

コマンドの長さは最大 16,384 バイトです。

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

CloudOps Orchestration Service(OOS)がアシュームする Resource Access Management(RAM)ロール。

String

いいえ

""

出力パラメーター

パラメーター

説明

タイプ

commandOutputs

List

テンプレートの実行に必要な権限ポリシー

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

詳細

ACS-ECS-BulkyRunCommand の詳細

テンプレートコンテンツ

FormatVersion: OOS-2019-06-01
Description:
  ja: '複数の Elastic Compute Service (ECS) インスタンスでクラウドアシスタントコマンドをバッチ実行します。このテンプレートは、アプリケーション管理やリソースのタグ付けなど、多数の ECS インスタンスを一度に管理する必要があるシナリオ向けです。テンプレートを設定する際には、リージョン ID (regionId)、リソースタイプ (resourceType)、ターゲットインスタンス (targets) などの必須パラメーターを指定する必要があります。また、コマンドタイプ (commandType) (Shell や Python など) とコマンド内容 (commandContent) も指定します。テンプレートの実行後、バッチ操作の出力が返されます。この出力を使用して、コマンドの実行ステータスを確認できます。'
  name-ja: コマンドの実行
  categories:
    - run_command
    - application_manage
    - computenest
    - tag_operate_resource
Parameters:
  regionId:
    Type: String
    Label:
      ja: リージョン ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  resourceType:
    Type: String
    Label:
      ja: リソースタイプ
    AssociationPropertyMetadata:
      LocaleKey: TargetResourceType
    AllowedValues:
      - ALIYUN::ECS::Instance
      - ALIYUN::ECS::ManagedInstance
    Default: ALIYUN::ECS::Instance
  targets:
    Type: Json
    Label:
      ja: ターゲットインスタンス
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: resourceType
      RegionId: regionId
      Status: Running
  commandType:
    Label:
      ja: コマンドタイプ
    AssociationPropertyMetadata:
      LocaleKey: ECSCommandType
    Type: String
    AllowedValues:
      - RunShellScript
      - RunPythonScript
      - RunPerlScript
      - RunBatScript
      - RunPowerShellScript
    Default: RunShellScript
  commandContent:
    Label:
      ja: コマンド内容
    Type: String
    MaxLength: 16384
    AssociationProperty: ALIYUN::OOS::Command::CommandContent
    AssociationPropertyMetadata:
      CommandType: ${commandType}
  workingDir:
    Description:
      ja: 'Linux インスタンスの場合、デフォルトは管理者 (root) のホームディレクトリである /root です。Windows インスタンスの場合、デフォルトはクラウドアシスタントクライアントのプロセスが存在するディレクトリ (例: C:\Windows\System32) です。入力するディレクトリが正しいことを確認してください。'
    Label:
      ja: 作業ディレクトリ
    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:
      ja: タイムアウト (秒)
    Type: Number
    Default: 600
  enableParameter:
    Label:
      ja: パラメーターの有効化
    Type: Boolean
    Default: false
  username:
    Description:
      ja: ECS インスタンスでコマンドを実行するためのユーザー名。ユーザー名は最大 255 文字です。Linux インスタンスの場合、コマンドはデフォルトで root ユーザーとして実行されます。Windows インスタンスの場合、コマンドはデフォルトで System ユーザーとして実行されます。入力するユーザー名が正しいことを確認してください。<a href="https://www.alibabacloud.com/help/doc-detail/203771.html" target="_blank">詳細はこちら</a>
    Label:
      ja: ユーザー名
    Type: String
    Default: ''
  windowsPasswordName:
    Label:
      ja: Windows ユーザーのパスワード名
    Type: String
    Default: ''
    AssociationProperty: ALIYUN::OOS::SecretParameter::Value
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Or:
            - Fn::Equals:
                - ${commandType}
                - RunBatScript
            - Fn::Equals:
                - ${commandType}
                - RunPowerShellScript
  rateControl:
    Label:
      ja: レートコントロール
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      ja: OOS が偽装する RAM ロール
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      ja: 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:
      ja: クラウドアシスタントコマンドを実行します
    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:
            ja: コマンド実行オプション
      - Parameters:
          - regionId
          - resourceType
          - targets
        Label:
          default:
            ja: インスタンスの選択
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            ja: 詳細オプション