模板名稱
ACS-ESS-RollingUpdateByConfigureOOSPackage 通過安裝OOS軟件包的方式滾動更新伸縮組內的ECS實例
模板描述
通過安裝OOS軟件包的方式滾動更新伸縮組內的ECS實例
模板類型
自動化
所有者
Alibaba Cloud
輸入參數
參數名稱 | 描述 | 類型 | 是否必填 | 默認值 | 約束 |
invokeType | 執行操作類型 | String | 是 | ||
scalingGroupId | 伸縮組ID | String | 是 | ||
packageName | 軟件包名稱 | String | 是 | ||
enterProcess | 執行開始要暫停的伸縮組流程 | List | 否 | ['ScaleIn', 'ScaleOut', 'HealthCheck', 'AlarmNotification', 'ScheduledAction'] | |
exitProcess | 執行結束要恢復的伸縮組流程 | List | 否 | ['ScaleIn', 'ScaleOut', 'HealthCheck', 'AlarmNotification', 'ScheduledAction'] | |
lifecycleState | 生命周期狀態 | List | 否 | InService | |
action | 配置方式 | String | 否 | install | |
packageVersion | 軟件包版本 | String | 否 | "" | |
sourceExecutionId | 用于回滾的OOS執行ID | String | 否 | "" | |
batchPauseOption | 分批模式 | String | 否 | Automatic | |
batchNumber | 分批執行的批次 | Number | 否 | 5 | |
OOSAssumeRole | OOS扮演的RAM角色 | String | 否 | "" |
輸出參數
參數名稱 | 描述 | 類型 |
commandOutputs | List |
執行此模板需要的權限策略
{
"Version": "1",
"Statement": [
{
"Action": [
"ess:DescribeScalingInstances",
"ess:EnterStandby",
"ess:ExitStandBy",
"ess:ResumeProcesses",
"ess:SetInstancesProtection",
"ess:SuspendProcesses"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeInvocationResults",
"ecs:DescribeInvocations",
"ecs:RunCommand",
"ecs:TagResources"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"oos:ListExecutions"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
詳情
ACS-ESS-RollingUpdateByConfigureOOSPackage詳情
模板內容
FormatVersion: OOS-2019-06-01
Description:
en: Rolling update ECS instances that in scaling group by configure oos package
zh-cn: 通過安裝OOS軟件包的方式滾動更新伸縮組內的ECS實例
name-en: ACS-ESS-RollingUpdateByConfigureOOSPackage
name-zh-cn: 通過安裝OOS軟件包的方式滾動更新伸縮組內的ECS實例
categories:
- elastic_manage
Parameters:
invokeType:
Label:
en: InvokeType
zh-cn: 執行操作類型
Type: String
AllowedValues:
- invoke
- rollback
scalingGroupId:
Label:
en: ScalingGroupId
zh-cn: 伸縮組ID
Type: String
enterProcess:
Label:
en: EnterProcess
zh-cn: 執行開始要暫停的伸縮組流程
Type: List
Default:
- ScaleIn
- ScaleOut
- HealthCheck
- AlarmNotification
- ScheduledAction
exitProcess:
Label:
en: ExitProcess
zh-cn: 執行結束要恢復的伸縮組流程
Type: List
Default:
- ScaleIn
- ScaleOut
- HealthCheck
- AlarmNotification
- ScheduledAction
lifecycleState:
Label:
en: LifecycleState
zh-cn: 生命周期狀態
Description:
en: The lifecycle state of the ECS instance to be upgraded
zh-cn: 要升級的ECS實例所處的生命周期狀態
Type: List
AllowedValues:
- InService
- Protected
Default: InService
action:
Label:
en: ConfigureAction
zh-cn: 配置方式
Description:
en: The action to configure package
zh-cn: 配置軟件包的方式
Type: String
AllowedValues:
- install
- uninstall
Default: install
packageName:
Label:
en: PackageName
zh-cn: 軟件包名稱
Type: String
packageVersion:
Label:
en: PackageVersion
zh-cn: 軟件包版本
Type: String
Default: ''
sourceExecutionId:
Label:
en: SourceExecutionId
zh-cn: 用于回滾的OOS執行ID
Type: String
Default: ''
batchPauseOption:
Label:
en: BatchPauseOption
zh-cn: 分批模式
Type: String
AllowedValues:
- Automatic
- FirstBatchPause
- EveryBatchPause
Default: Automatic
batchNumber:
Label:
en: BatchNumber
zh-cn: 分批執行的批次
Type: Number
MinValue: 1
MaxValue: 100
Default: 5
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: OOS扮演的RAM角色
Type: String
Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: choiceNextTask
Action: 'ACS::Choice'
Description:
en: Choose next task by invoke type
zh-cn: 根據執行類型選擇任務
Properties:
DefaultTask: getInstance
Choices:
- When:
'Fn::Equals':
- rollback
- '{{ invokeType }}'
NextTask: getExecutionInstanceIds
- Name: getInstance
Description:
en: Views the ECS instances
zh-cn: 獲取ECS實例
Action: 'ACS::ExecuteApi'
Properties:
Service: ESS
API: DescribeScalingInstances
Parameters:
ScalingGroupId: '{{ scalingGroupId }}'
LifecycleStates: '{{ lifecycleState }}'
CreationTypes:
- AutoCreated
- Attached
Outputs:
instanceIds:
Type: List
ValueSelector: 'ScalingInstances.ScalingInstance | map({"InstanceId": (.InstanceId), "LifecycleState": (.LifecycleState)})[]'
- Name: whetherTheScalingGroupInstanceIsEmpty
Action: 'ACS::Choice'
Description:
en: Check whether the instances in the services in the scaling group are empty
zh-cn: 檢查伸縮組內服務中的實例是否為空
Properties:
DefaultTask: whetherToSuspendProcess
Choices:
- When:
'Fn::Equals':
- [ ]
- '{{ getInstance.instanceIds }}'
NextTask: 'ACS::END'
- Name: whetherToSuspendProcess
Action: 'ACS::Choice'
Description:
en: Choose next task by process
zh-cn: 根據流程值判斷是否暫停流程
Properties:
DefaultTask: suspendProcess
Choices:
- When:
'Fn::Equals':
- []
- '{{ enterProcess }}'
NextTask: invokeByConfigureOOSPackage
- Name: suspendProcess
Action: 'ACS::ExecuteAPI'
Description:
en: Suspend process
zh-cn: 暫停伸縮組流程
Properties:
Service: ESS
API: SuspendProcesses
Parameters:
ScalingGroupId: '{{ scalingGroupId }}'
Process: '{{ enterProcess }}'
- Name: invokeByConfigureOOSPackage
Action: 'ACS::ESS::ConfigureOOSPackage'
Description:
en: Configure OOS package
zh-cn: 安裝OOS軟件包
Properties:
instanceId:
Fn::Select:
- 'InstanceId'
- '{{ ACS::TaskLoopItem }}'
lifecycleState:
Fn::Select:
- 'LifecycleState'
- '{{ ACS::TaskLoopItem }}'
action: '{{ action }}'
packageName: '{{ packageName }}'
packageVersion: '{{ packageVersion }}'
scalingGroupId: '{{ scalingGroupId }}'
Loop:
Items: '{{ getInstance.instanceIds }}'
BatchPauseOption: '{{ batchPauseOption }}'
Concurrency:
'Fn::CalculateBatch':
- '{{ batchNumber }}'
- '{{ getInstance.instanceIds }}'
Outputs:
commandOutputs:
AggregateType: 'Fn::ListJoin'
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: commandOutput
- Name: tagInstance
Action: ACS::ExecuteApi
Description:
en: Creates and attaches tag to ECS instance
zh-cn: 創建并掛載標簽到ECS實例
Properties:
Service: ECS
API: TagResources
Parameters:
ResourceIds:
- Fn::Select:
- 'InstanceId'
- '{{ ACS::TaskLoopItem }}'
ResourceType: Instance
Tags:
- Key: 'ess:rollingupdate'
Value: 'oos:{{ ACS::ExecutionId }}'
Loop:
Items: '{{ getInstance.instanceIds }}'
Mode: Concurrency
MaxErrors: 0
Concurrency: 10
- Name: whetherToResumeProcesses
Action: 'ACS::Choice'
Description:
en: Choose next task by process
zh-cn: 根據流程值判斷是否恢復流程
Properties:
DefaultTask: resumeProcesses
Choices:
- When:
'Fn::Equals':
- []
- '{{ exitProcess }}'
NextTask: 'ACS::END'
- Name: resumeProcesses
Action: 'ACS::ExecuteAPI'
OnSuccess: 'ACS::END'
Description:
en: Resume process
zh-cn: 恢復伸縮組流程
Properties:
Service: ESS
API: ResumeProcesses
Parameters:
ScalingGroupId: '{{ scalingGroupId }}'
Process: '{{ exitProcess }}'
- Name: getExecutionInstanceIds
Action: 'ACS::ExecuteAPI'
Description:
en: Get the instance that has been installed package
zh-cn: 獲取已經安裝過軟件包的實例
Properties:
Service: OOS
API: ListExecutions
Parameters:
ParentExecutionId: '{{ sourceExecutionId }}'
Outputs:
instanceIds:
Type: List
ValueSelector: 'Executions[].Parameters.instanceId'
lifecycleStates:
Type: List
ValueSelector: '.Executions | map({"InstanceId": (.Parameters.instanceId), "LifecycleState": (.Parameters.lifecycleState)})[]'
- Name: getExistInstanceIds
Description:
en: Views the ECS existed instances
zh-cn: 獲取存在ECS實例
Action: ACS::SelectTargets
Properties:
ResourceType: ALIYUN::ECS::Instance
Filters:
- Type: ResourceIds
ResourceIds: '{{ getExecutionInstanceIds.instanceIds }}'
Outputs:
instanceIds:
Type: List
ValueSelector: Instances.Instance[].InstanceId
- Name: getRollbackProcess
Action: 'ACS::ExecuteAPI'
Description:
en: Views resource parameters
zh-cn: 獲取源執行的參數
Properties:
Service: OOS
API: ListExecutions
Parameters:
ExecutionId: '{{ sourceExecutionId }}'
Outputs:
enterProcess:
Type: List
ValueSelector: 'Executions[].Parameters.enterProcess[]'
exitProcess:
Type: List
ValueSelector: 'Executions[].Parameters.exitProcess[]'
- Name: suspendProcessWithRollBack
Action: 'ACS::ExecuteAPI'
Description:
en: Suspend process
zh-cn: 暫停伸縮組流程
Properties:
Service: ESS
API: SuspendProcesses
Parameters:
ScalingGroupId: '{{ scalingGroupId }}'
Process: '{{ getRollbackProcess.enterProcess }}'
- Name: rollbackByConfigureOOSPackage
Action: 'ACS::ESS::ConfigureOOSPackage'
Description:
en: Configure OOS package
zh-cn: 安裝OOS軟件包
Properties:
instanceId: '{{ ACS::TaskLoopItem }}'
lifecycleState:
Fn::Jq:
- First
- '.[] | select(.InstanceId == "{{ ACS::TaskLoopItem }}") | .LifecycleState'
- '{{ getExecutionInstanceIds.lifecycleStates }}'
action: '{{ action }}'
packageName: '{{ packageName }}'
packageVersion: '{{ packageVersion }}'
scalingGroupId: '{{ scalingGroupId }}'
Loop:
Items: '{{ getExistInstanceIds.instanceIds }}'
BatchPauseOption: '{{ batchPauseOption }}'
Concurrency:
'Fn::CalculateBatch':
- '{{ batchNumber }}'
- '{{ getExistInstanceIds.instanceIds }}'
Outputs:
commandOutputs:
AggregateType: 'Fn::ListJoin'
AggregateField: commandOutput
Outputs:
commandOutput:
Type: String
ValueSelector: commandOutput
- Name: whetherToResumeProcessesWithRollback
Action: 'ACS::Choice'
Description:
en: Choose next task by process
zh-cn: 根據流程值判斷是否恢復流程
Properties:
DefaultTask: resumeProcessesWithRollback
Choices:
- When:
'Fn::Equals':
- []
- '{{ getRollbackProcess.exitProcess }}'
NextTask: 'ACS::END'
- Name: resumeProcessesWithRollback
Action: 'ACS::ExecuteAPI'
Description:
en: Resume process
zh-cn: 恢復伸縮組流程
Properties:
Service: ESS
API: ResumeProcesses
Parameters:
ScalingGroupId: '{{ scalingGroupId }}'
Process: '{{ getRollbackProcess.exitProcess }}'
Outputs:
commandOutputs:
Type: List
Value:
'Fn::If':
- 'Fn::Equals':
- invoke
- '{{ invokeType }}'
- '{{ invokeByConfigureOOSPackage.commandOutputs }}'
- '{{ rollbackByConfigureOOSPackage.commandOutputs }}'
文檔內容是否對您有幫助?