-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathACS::ECS::ConfigureOOSUtil.yml
89 lines (89 loc) · 2.53 KB
/
ACS::ECS::ConfigureOOSUtil.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
FormatVersion: OOS-2019-06-01
Description:
name-en: ACS::ECS::ConfigureOOSUtil
name-zh-cn: 安装OOSUtil
en: Install OOS util
zh-cn: 安装OOSUtil
Parameters:
regionId:
Description:
en: The ID of region
zh-cn: 地域ID
Type: String
Default: '{{ ACS::RegionId }}'
instanceId:
Description:
en: The ID of ECS instance
zh-cn: ECS实例ID
Type: String
MaxLength: 30
MinLength: 1
version:
Description:
en: The version of OOS util
zh-cn: OOSUtil的版本
Type: String
Default: '{{ ACS::OOSUtilVersion }}'
Tasks:
- Name: queryInstanceOSType
Action: ACS::ExecuteApi
Description:
en: Queries ECS instance OS type
zh-cn: 查询ECS实例的操作系统类型。
Properties:
Service: ECS
API: DescribeInstances
Parameters:
RegionId: '{{ regionId }}'
InstanceIds:
- '{{ instanceId }}'
Outputs:
OSType:
Type: String
ValueSelector: Instances.Instance[].OSType
- Name: runCommand
Action: 'ACS::ECS::RunCommand'
Description:
en: Executes cloud assistant command to configure OOS util
zh-cn: 通过执行云助手命令安装OOSUtil
Properties:
commandContent:
'Fn::If':
- 'Fn::Equals':
- linux
- '{{ queryInstanceOSType.OSType }}'
- |-
version='{{ version }}'
path=/usr/local/share/aliyun-oosutil/$version
test -e $path || mkdir -p $path
cd $path && test -e oosutil_linux || wget "https://oos-public-{{regionId}}.oss-{{regionId}}-internal.aliyuncs.com/oosutil/$version/linux/oosutil_linux"
chmod +x oosutil_linux
- |-
$version='{{ version }}'
$path = "C:\aliyun-oosutil\$version"
$pathExistOrNot = Test-Path -Path "$path"
if ($pathExistOrNot){
cd $path
}else{
mkdir $path
cd $path
}
$client = new-object System.Net.WebClient
$client.DownloadFile("https://oos-public-{{regionId}}.oss-{{regionId}}-internal.aliyuncs.com/oosutil/$version/windows/oosutil_windows.exe", "$path/oosutil_windows.exe")
instanceId: '{{ instanceId }}'
regionId: '{{ regionId }}'
commandType:
'Fn::If':
- 'Fn::Equals':
- linux
- '{{ queryInstanceOSType.OSType }}'
- RunShellScript
- RunPowerShellScript
Outputs:
commandOutput:
Type: String
ValueSelector: invocationOutput
Outputs:
commandOutput:
Type: String
Value: '{{ runCommand.commandOutput }}'