全部產品
Search
文件中心

CloudOps Orchestration Service:ACS-ECS-RunRemoteShellScript

更新時間:Sep 06, 2024

模板名稱

ACS-ECS-RunRemoteShellScript 運行遠端shell指令碼

立即執行

模板描述

運行遠端shell指令碼

模板類型

自動化

所有者

Alibaba Cloud

輸入參數

參數名稱

描述

類型

是否必填

預設值

約束

instanceId

ECS執行個體

String

是

instanceRole

掛載到執行個體上的RAM角色

String

是

fileName

執行的檔案名稱

String

是

srcUrl

檔案在OSS中的目錄

String

是

destUrl

檔案複製到ECS執行個體中的目錄

String

是

regionId

地區ID

String

否

{{ ACS::RegionId }}

workingDir

在執行個體中運行命令的目錄

String

否

/root

timeout

運行命令最大逾時時間

Number

否

600

OOSAssumeRole

OOS扮演的RAM角色

String

否

“”

輸出參數

參數名稱

描述

類型

commandOutput

String

執行此模板需要的權限原則

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

詳情

ACS-ECS-RunRemoteShellScript詳情

模板內容

FormatVersion: OOS-2019-06-01
Description:
  en: Run remote shell script
  zh-cn: 運行遠端shell指令碼
  name-en: ACS-ECS-RunRemoteShellScript
  name-zh-cn: 運行遠端shell指令碼
  categories:
    - run_command
Parameters:
  regionId:
    Label:
      en: RegionId
      zh-cn: 地區ID
    Type: String
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  instanceId:
    Label:
      en: InstanceId
      zh-cn: ECS執行個體
    Type: String
    AssociationProperty: ALIYUN::ECS::Instance::InstanceId
    AssociationPropertyMetadata:
      RegionId: regionId
  instanceRole:
    Label:
      en: InstanceRole
      zh-cn: 掛載到執行個體上的RAM角色
    Type: String
  fileName:
    Label:
      en: FileName
      zh-cn: 執行的檔案名稱
    Type: String
  srcUrl:
    Label:
      en: SrcUrl
      zh-cn: 檔案在OSS中的目錄
    Type: String
  destUrl:
    Label:
      en: DestUrl
      zh-cn: 檔案複製到ECS執行個體中的目錄
    Type: String
  workingDir:
    Label:
      en: WorkingDir
      zh-cn: 在執行個體中運行命令的目錄
    Type: String
    Default: /root
  timeout:
    Label:
      en: Timeout
      zh-cn: 運行命令最大逾時時間
    Type: Number
    Default: 600
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: copyOSSFileToInstance
    Description:
      en: Copies OSS file to linux instace
      zh-cn: 複製OSS中的檔案到Linux執行個體中
    Action: 'ACS::ECS::CopyLinuxInstanceFileFromOSS'
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ instanceId }}'
      instanceRole: '{{ instanceRole }}'
      srcUrl: '{{ srcUrl }}/{{ fileName }}'
      destUrl: '{{ destUrl }}'
  - Name: runCommand
    Description:
      en: Execute cloud assistant command
      zh-cn: 執行雲助手命令
    Action: 'ACS::ECS::RunCommand'
    Properties:
      regionId: '{{ regionId }}'
      commandContent: '/bin/bash {{ destUrl }}/{{ fileName }}'
      instanceId: '{{ instanceId }}'
      commandType: RunShellScript
      workingDir: '{{ workingDir }}'
      timeout: '{{ timeout }}'
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: invocationOutput
Outputs:
  commandOutput:
    Type: String
    Value: '{{ runCommand.commandOutput }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - instanceRole
          - fileName
          - srcUrl
          - destUrl
          - workingDir
          - timeout
        Label:
          default:
            zh-cn: 執行Shell指令碼選型
            en: Run Shell Script Options
      - Parameters:
          - instanceId
        Label:
          default:
            zh-cn: 選擇執行個體
            en: Select ECS Instance
      - Parameters:
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 進階選項
            en: Control Options