テンプレート名
ACS-ECS-RunRemoteShellScript
テンプレートの説明
Elastic Compute Service (ECS) インスタンスでリモートシェルスクリプトを実行します。
テンプレートタイプ
自動化
所有者
Alibaba Cloud
入力パラメータ
パラメータ | 説明 | タイプ | 必須 | デフォルト値 | 制限 |
instanceId | ECS インスタンスの ID。 | String | はい | ||
instanceRole | ECS インスタンスにアタッチされている Resource Access Management (RAM) ロール。 | String | はい | ||
fileName | 実行するスクリプトファイルの名前。 | String | はい | ||
srcUrl | スクリプトファイルが Object Storage Service (OSS) に保存されているディレクトリ。 | String | はい | ||
destUrl | スクリプトファイルが ECS インスタンスにコピーされるディレクトリ。 | String | はい | ||
regionId | リージョン ID。 | String | いいえ | {{ ACS::RegionId }} | |
workingDir | ECS インスタンスでコマンドが実行されるディレクトリ。 | String | いいえ | /root | |
timeout | コマンド実行の最大タイムアウト期間。 | Number | いいえ | 600 | |
OOSAssumeRole | CloudOps Orchestration Service (OOS) によって引き受けられる Resource Access Management (RAM) ロール。 | String | いいえ | "" |
出力パラメータ
パラメータ | 説明 | タイプ |
commandOutput | String |
テンプレートを実行するために必要な権限ポリシー
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeInstanceRAMRole",
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
参照
詳細については、GitHub の ACS-ECS-RunRemoteShellScript.yml をご参照ください。
テンプレートコンテンツ
FormatVersion: OOS-2019-06-01
Description:
en: Run remote shell script
zh-cn: the description in Chinese
name-en: ACS-ECS-RunRemoteShellScript
name-zh-cn: the description in Chinese
categories:
- run_command
Parameters:
regionId:
Label:
en: RegionId
zh-cn: the description in Chinese
Type: String
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
instanceId:
Label:
en: InstanceId
zh-cn: the description in Chinese
Type: String
AssociationProperty: ALIYUN::ECS::Instance::InstanceId
AssociationPropertyMetadata:
RegionId: regionId
instanceRole:
Label:
en: InstanceRole
zh-cn: the description in Chinese
Type: String
fileName:
Label:
en: FileName
zh-cn: the description in Chinese
Type: String
srcUrl:
Label:
en: SrcUrl
zh-cn: the description in Chinese
Type: String
destUrl:
Label:
en: DestUrl
zh-cn: the description in Chinese
Type: String
workingDir:
Label:
en: WorkingDir
zh-cn: the description in Chinese
Type: String
Default: /root
timeout:
Label:
en: Timeout
zh-cn: the description in Chinese
Type: Number
Default: 600
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: the description in Chinese
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: copyOSSFileToInstance
Description:
en: Copies OSS file to linux instace
zh-cn: the description in Chinese
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: the description in Chinese
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: the description in Chinese
en: Run Shell Script Options
- Parameters:
- instanceId
Label:
default:
zh-cn: the description in Chinese
en: Select ECS Instance
- Parameters:
- OOSAssumeRole
Label:
default:
zh-cn: the description in Chinese
en: Control Options