ACS-ECS-RunRemoteShellScript

更新时间:
复制 MD 格式

模板名称

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