すべてのプロダクト
Search
ドキュメントセンター

CloudOps Orchestration Service:ACS-ESS-RollingUpdateByConfigureOOSPackage によるローリングアップデート

最終更新日:Jan 17, 2025

テンプレート名

ACS-ESS-RollingUpdateByConfigureOOSPackage

今すぐ実行

テンプレートの説明

CloudOps Orchestration Service (OOS) ソフトウェアパッケージをインストールして、スケーリンググループ内の Elastic Compute Service (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

ロールバックされる CloudOps Orchestration Service (OOS) 実行の ID。

String

いいえ

""

batchPauseOption

一時停止ポリシー。

String

いいえ

Automatic

batchNumber

バッチ数。

Number

いいえ

5

OOSAssumeRole

OOS によってアシュームされる Resource Access Management (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 }}'