全部产品
Search
文档中心

CloudOps Orchestration Service:ACS-ECS-BulkyDownloadFileAndRunCommand

更新时间:Dec 21, 2025

Nama Template

ACS-ECS-BulkyDownloadFileAndRunCommand mengunduh file ke beberapa instance ECS dan mengeksekusi perintah Cloud Assistant.

Eksekusi Sekarang

Deskripsi Template

Mengunduh file ke beberapa instance Elastic Compute Service (ECS) sekaligus dan menjalankan perintah Cloud Assistant pada instance ECS tersebut.

Tipe Template

Otomatis

Pemilik

Alibaba Cloud

Parameter Input

Parameter

Deskripsi

Tipe

Diperlukan

Nilai Default

Batasan

targets

Target instance

Json

Ya

sourcePath

Select a file

String

Ya

destinationDir

Direktori tempat file akan diunduh di instance ECS.

String

Ya

regionId

ID wilayah.

String

Tidak

{{ ACS::RegionId }}

sourceType

Tipe file.

String

Tidak

local

commandContent

Konten perintah.

String

Tidak

# #Contoh penerapan 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 &

Perintah dapat memiliki panjang hingga 16.384 byte.

workingDir

Direktori tempat perintah akan dijalankan pada instance ECS.

String

Tidak

""

timeout

Jangka waktu timeout untuk menjalankan perintah pada instance ECS.

Number

Tidak

600

rateControl

Rasio konkurensi eksekusi tugas

Json

Tidak

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

OOSAssumeRole

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

String

Tidak

""

Parameter keluaran

Tidak ada

Kebijakan Izin yang Diperlukan untuk Menjalankan Template

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

Detail

Untuk informasi lebih lanjut, lihat ACS-ECS-BulkyDownloadFileAndRunCommand.yml di GitHub.

Konten Template

FormatVersion: OOS-2019-06-01
Description:
  en: Batch download files to multiple ECS instances and run Cloud Assistant commands
  zh-cn: 批量下载文件到多个ECS实例并执行云助手命令
  name-en: ACS-ECS-BulkyDownloadFileAndRunCommand
  name-zh-cn: 批量下载文件到多个ECS实例并执行云助手命令
  categories:
    - instance_manage
    - application_manage
Parameters:
  regionId:
    Type: String
    Label:
      en: Region ID
      zh-cn: 地域ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  targets:
    Label:
      en: Target Instance
      zh-cn: 目标实例
    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 public network access enabled.</font></li><li class="li"><font color='red'>To download files from OSS, the target ECS instances must be configured with a RAM role. 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>
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
  sourceType:
    Type: String
    Description:
      en: The size of a file uploaded from your local machine cannot exceed 500 MB.
      zh-cn: 本地上传文件不能超过500M
    Label:
      en: Source Type
      zh-cn: 文件类型
    AllowedValues:
      - local
      - oss
      - https
    Default: local
    AssociationPropertyMetadata:
      LocaleKey: DownloadFileType
      RegionId: ${regionId}
  sourcePath:
    Type: String
    Label:
      en: Source File
      zh-cn: 选择文件
    AssociationProperty: ALIYUN::OOS::File::FileUrl
    AssociationPropertyMetadata:
      FileType: ${sourceType}
      RegionId: ${regionId}
  destinationDir:
    Label:
      en: Destination Directory
      zh-cn: 实例中文件复制的目标目录
    Type: String
  commandContent:
    Label:
      en: Command Content
      zh-cn: 命令内容
    Type: String
    MaxLength: 16384
    AssociationProperty: ALIYUN::OOS::Command::CommandContent
    AssociationPropertyMetadata:
      CommandType: RunShellScript
    Default: |
      # Contoh penerapan 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实例中的运行目录
    Description:
      en: 'The directory on the ECS instance where the script runs. For Linux instances, the default directory is the home directory of the root user (/root). For Windows instances, the default directory 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。'
    Type: String
    Default: ''
  timeout:
    Label:
      en: Command Timeout
      zh-cn: ECS实例中执行命令的超时时间
    Type: Number
    Default: 600
  rateControl:
    Label:
      en: Concurrency Rate
      zh-cn: 任务执行的并发比率
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: RAM Role for OOS
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Retrieves the specified ECS instances.
      zh-cn: 获取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 instances and runs the command.
      zh-cn: 下载文件到实例并执行命令
    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
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            zh-cn: 选择实例
            en: Instance Selection
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 高级选项
            en: Advanced Options