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

CloudOps Orchestration Service:ACS-ECS-BulkyDownloadFileAndRunCommand

最終更新日:Jun 23, 2026

テンプレート名

ACS-ECS-BulkyDownloadFileAndRunCommand:複数の Elastic Compute Service (ECS) インスタンスにファイルをダウンロードし、Cloud Assistant コマンドを実行します。

今すぐ実行

テンプレートの説明

複数の ECS インスタンスにファイルをダウンロードし、Cloud Assistant コマンドを実行します。

テンプレートタイプ

オートメーション

所有者

Alibaba Cloud

入力パラメーター

パラメーター

説明

タイプ

必須

デフォルト値

制約

targets

ターゲット ECS インスタンス。

Json

はい

sourcePath

ソースファイル。

String

はい

destinationDir

ダウンロードしたファイルを ECS インスタンスに保存する宛先ディレクトリ。

String

はい

regionId

リージョン ID。

String

いいえ

{{ ACS::RegionId }}

sourceType

ソースファイルのタイプ。

String

いいえ

local

commandContent

実行するコマンド。

String

いいえ

# Java デプロイの例
# java_pid=`ps -ef | grep java | grep -v grep | awk '{print$2}'`
# if [[ $java_pid ]];then
#   kill -9 $java_pid
# fi
# nohup java -jar *.jar &

最大長:16384 バイト。

workingDir

ECS インスタンスでコマンドを実行するディレクトリ。

String

いいえ

""

timeout

コマンド実行のタイムアウト時間 (秒)。

Number

いいえ

600

rateControl

タスク実行の同時実行制御。

Json

いいえ

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

OOSAssumeRole

タスクの実行時に Operation Orchestration Service (OOS) が引き受ける RAM ロール。

String

いいえ

""

出力パラメーター

なし

必要な許可ポリシー

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

詳細

ACS-ECS-BulkyDownloadFileAndRunCommand の詳細

テンプレートの内容

FormatVersion: OOS-2019-06-01
Description:
  en: Downloads a file to multiple ECS instances and runs a Cloud Assistant command.
  zh-cn: 批量下载文件到多个ECS实例并执行云助手命令
  ja: 複数の ECS インスタンスにファイルをダウンロードし、Cloud Assistant コマンドを実行します。
  name-en: ACS-ECS-BulkyDownloadFileAndRunCommand
  name-zh-cn: 批量下载文件到多个ECS实例并执行云助手命令
  name-ja: 複数の ECS インスタンスへのファイルの一括ダウンロードと Cloud Assistant コマンドの実行
  categories:
    - instance_manage
    - application_manage
Parameters:
  regionId:
    Type: String
    Label:
      en: Region ID
      zh-cn: 地域ID
      ja: リージョン ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  targets:
    Label:
      en: Target instance
      zh-cn: 目标实例
      ja: ターゲットインスタンス
    Type: Json
    Description:
      en: <p class="p">Notes:</p> <ul class="ul"> <li class="li"><font color='red'>To download files over HTTPS, the target ECS instances must have access to the public network.</font></li><li class="li"><font color='red'>To download files from OSS, a RAM role must be attached to the target ECS instances. For more information, see <a href='https://www.alibabacloud.com/help/en/operation-orchestration-service/latest/download-multiple-objects-to-an-instance#vOk3w'>this document</a>.</font></li>
      zh-cn: <p class="p">注意事项:</p> <ul class="ul"> <li class="li"><font color='red'>通过https方式下载需要ECS实例开启公网访问</font></li><li class="li"><font color='red'>通过oss方式下载需要ECS实例配置RAM角色,<a href='https://www.alibabacloud.com/help/document_detail/175396.html?spm=a2c4g.120556.0.0.34c9de53iyt2Z1#vOk3w'>参考文档</a></font></li>
      ja: <p class="p">注意事項:</p> <ul class="ul"> <li class="li"><font color='red'>HTTPS 経由でファイルをダウンロードするには、ターゲットの ECS インスタンスがパブリックネットワークにアクセスできる必要があります。</font></li><li class="li"><font color='red'>OSS からファイルをダウンロードするには、RAM ロールをターゲットの ECS インスタンスにアタッチする必要があります。詳細については、<a href='https://www.alibabacloud.com/help/operation-orchestration-service/latest/download-multiple-objects-to-an-instance#vOk3w'>このドキュメント</a>をご参照ください。</font></li>
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
  sourceType:
    Type: String
    Description:
      en: The maximum size for files uploaded from your local computer is 500 MB.
      zh-cn: 本地上传文件不能超过500M
      ja: ローカルコンピューターからアップロードされるファイルの最大サイズは 500 MB です。
    Label:
      en: Source type
      zh-cn: 文件类型
      ja: ソースタイプ
    AllowedValues:
      - local
      - oss
      - https
    Default: local
    AssociationPropertyMetadata:
      LocaleKey: DownloadFileType
      RegionId: ${regionId}
  sourcePath:
    Type: String
    Label:
      en: Source file
      zh-cn: 选择文件
      ja: ソースファイル
    AssociationProperty: ALIYUN::OOS::File::FileUrl
    AssociationPropertyMetadata:
      FileType: ${sourceType}
      RegionId: ${regionId}
  destinationDir:
    Label:
      en: Destination directory
      zh-cn: 实例中文件复制的目标目录
      ja: 宛先ディレクトリ
    Type: String
  commandContent:
    Label:
      en: Command content
      zh-cn: 命令内容
      ja: コマンド内容
    Type: String
    MaxLength: 16384
    AssociationProperty: ALIYUN::OOS::Command::CommandContent
    AssociationPropertyMetadata:
      CommandType: RunShellScript
    Default: |
      # Java デプロイの例
      # java_pid=`ps -ef | grep java | grep -v grep | awk '{print$2}'`
      # if [[ $java_pid ]];then
      #   kill -9 $java_pid
      # fi
      # nohup java -jar *.jar &
  workingDir:
    Label:
      en: Working directory
      zh-cn: 脚本在ECS实例中的运行目录
      ja: 作業ディレクトリ
    Description:
      en: 'The directory on the ECS instance from which the script runs. For Linux instances, the default is the home directory of the root user (/root). For Windows instances, the default is the directory where the Cloud Assistant client process is located, such as C:\Windows\System32.'
      zh-cn: '脚本在ECS实例中的运行目录。Linux系统实例默认在管理员(root用户)的home目录下,即/root。Windows系统实例默认在云助手客户端进程所在目录,例如C:\Windows\System32。'
      ja: 'スクリプトが実行される ECS インスタンス上のディレクトリ。Linux インスタンスの場合、デフォルトは root ユーザーのホームディレクトリ (/root) です。Windows インスタンスの場合、デフォルトは Cloud Assistant クライアントプロセスが配置されているディレクトリ (C:\Windows\System32 など) です。'
    Type: String
    Default: ''
  timeout:
    Label:
      en: Command timeout
      zh-cn: ECS实例中执行命令的超时时间
      ja: コマンドのタイムアウト
    Type: Number
    Default: 600
  rateControl:
    Label:
      en: Concurrency rate
      zh-cn: 任务执行的并发比率
      ja: 同時実行制御
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: RAM role for OOS
      zh-cn: OOS扮演的RAM角色
      ja: OOS の RAM ロール
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Selects the target ECS instances.
      zh-cn: 获取ECS实例
      ja: ターゲットの ECS インスタンスを選択します。
    Action: 'ACS::SelectTargets'
    Properties:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: '{{ regionId }}'
      Filters:
        - '{{ targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: 'Instances.Instance[].InstanceId'
  - Name: downloadFileAndRunCommand
    Action: ACS::ECS::DownloadFileAndRunCommand
    Description:
      en: Downloads the file to the target instances and runs the command.
      zh-cn: 下载文件到实例并执行命令
      ja: ターゲットインスタンスにファイルをダウンロードし、コマンドを実行します。
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      sourceType: '{{ sourceType }}'
      sourcePath: '{{ sourcePath }}'
      destinationDir: '{{ destinationDir }}'
      commandContent: '{{ commandContent }}'
      workingDir: '{{ workingDir }}'
      timeout: '{{ timeout }}'
    Loop:
      Items: '{{ getInstance.instanceIds }}'
      RateControl: '{{ rateControl }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - sourceType
          - sourcePath
          - commandContent
          - destinationDir
          - workingDir
          - timeout
        Label:
          default:
            zh-cn: 配置参数
            en: Configuration parameters
            ja: 設定パラメーター
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            zh-cn: 选择实例
            en: Select instances
            ja: インスタンスの選択
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 高级选项
            en: Advanced options
            ja: 詳細オプション