All Products
Search
Document Center

CloudOps Orchestration Service:ACS-ECS-ScheduleApplyPatchBaseline

Last Updated:Nov 25, 2024

Template name

ACS-ECS-ScheduleApplyPatchBaseline

Execute Now

Template description

Configures a patch baseline for Elastic Compute Service (ECS) instances as scheduled.

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Type

Required

Default value

Limit

targets

The ECS instances for which you want to configure a patch baseline.

Json

Yes

timerTrigger

The type of the scheduled task.

Json

Yes

regionId

The region ID.

String

No

{{ ACS::RegionId }}

resourceType

The resource type.

String

No

ALIYUN::ECS::Instance

action

The execution mode.

String

No

install

whetherCreateSnapshot

Specifies whether to create a snapshot for the system disk.

Boolean

No

False

retentionDays

The retention period of the snapshot.

Number

No

7

rebootIfNeed

Specifies whether to restart the ECS instance if needed.

Boolean

No

False

timeout

The timeout period for running commands on the ECS instances.

Number

No

7200

rateControl

The rate control settings.

Json

No

{'Mode': 'Concurrency', 'MaxErrors': '0', 'Concurrency': 10}

OOSAssumeRole

The Resource Access Management (RAM) role that is assumed by CloudOps Orchestration Service (OOS).

String

No

""

Output parameters

Parameter

Description

Type

commandOutputs

List

Permission policy that is required to execute the template

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:CreateSnapshot",
                "ecs:DescribeCloudAssistantStatus",
                "ecs:DescribeDisks",
                "ecs:DescribeInstances",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:DescribeManagedInstances",
                "ecs:DescribeSnapshots",
                "ecs:RebootInstance",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ecd:CreateSnapshot",
                "ecd:DescribeCloudAssistantStatus",
                "ecd:DescribeDesktops",
                "ecd:DescribeInvocations",
                "ecd:DescribeSnapshots",
                "ecd:RebootDesktops",
                "ecd:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oos:ListInstancePatchStates"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

References

For more information, see ACS-ECS-ScheduleApplyPatchBaseline.yml at GitHub.

Template content

FormatVersion: OOS-2019-06-01
Description:
  name-en: ACS-ECS-ScheduleApplyPatchBaseline
  name-zh-cn: the description in Chinese
  en: Schedule to apply patch baseline on ECS instance
  zh-cn: the description in Chinese
Parameters:
  regionId:
    Label:
      en: RegionId
      zh-cn: the description in Chinese
    Type: String
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  resourceType:
    Type: String
    Label:
      en: ResourceType
      zh-cn: the description in Chinese
    AssociationPropertyMetadata:
      LocaleKey: TargetResourceType
    AllowedValues:
      - ALIYUN::ECS::Instance
      - ALIYUN::ECS::ManagedInstance
      - ALIYUN::ECD::Desktop
    Default: ALIYUN::ECS::Instance
  targets:
    Type: Json
    Label:
      en: TargetInstance
      zh-cn: the description in Chinese
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: resourceType
      RegionId: regionId
      Status: Running
  timerTrigger:
    Type: Json
    Label:
      en: TimerTrigger
      zh-cn: the description in Chinese
    AssociationProperty: ALIYUN::OOS::Component::TimerTrigger
    AssociationPropertyMetadata:
      MinuteInterval: 30
  action:
    Label:
      en: Action
      zh-cn: the description in Chinese
    Type: String
    AllowedValues:
      - install
      - scan
    Default: install
    AssociationPropertyMetadata:
      LocaleKey: OOSPatchExecuteType
  whetherCreateSnapshot:
    Label:
      en: WhetherCreateSnapshot
      zh-cn: the description in Chinese
    Type: Boolean
    Default: false
    AssociationPropertyMetadata:
      Visible:
        Condition:
            'Fn::Equals':
              - '${action}'
              - install
  retentionDays:
    Label:
      en: RetentionDays
      zh-cn: the description in Chinese
    Type: Number
    MinValue: 1
    MaxValue: 65536
    Default: 7
    AssociationPropertyMetadata:
      Visible:
        Condition:
            'Fn::Equals':
              - '${whetherCreateSnapshot}'
              - true
  rebootIfNeed:
    Label:
      en: RebootIfNeed
      zh-cn: the description in Chinese
    Type: Boolean
    Default: false
    AssociationPropertyMetadata:
      Visible:
        Condition:
            'Fn::Equals':
              - '${action}'
              - install
  timeout:
    Label:
      en: Timeout
      zh-cn: the description in Chinese
    Type: Number
    Default: 7200
  rateControl:
    Label:
      en: RateControl
      zh-cn: the description in Chinese
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: the description in Chinese
    Type: String
    Default: ''
    AssociationPropertyMetadata:
      TimerTrigger: '${timerTrigger}'
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: timerTrigger
    Action: ACS::TimerTrigger
    Description:
      en: Triggers a task as scheduled by specifying type and expression
      zh-cn: the description in Chinese
    Properties:
      Type:
        Fn::Select:
          - type
          - '{{timerTrigger}}'
      Expression:
        Fn::Select:
          - expression
          - '{{timerTrigger}}'
      EndDate:
        Fn::Select:
          - endDate
          - '{{ timerTrigger }}'
      TimeZone:
        Fn::Select:
          - timeZone
          - '{{ timerTrigger }}'
  - Name: getInstance
    Description:
      en: Views the ECS instances
      zh-cn: the description in Chinese
    Action: ACS::SelectTargets
    Properties:
      RegionId: '{{ regionId }}'
      ResourceType: '{{ resourceType }}'
      Filters:
        - '{{ targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: Instances.Instance[].InstanceId
  - Name: applyPatchBaseline
    Description:
      en: Apply patch baseline on ECS instance
      zh-cn: the description in Chinese
    Action: ACS::ECS::ApplyPatchBaseline
    When:
      Fn::Equals:
        - '{{ resourceType }}'
        - ALIYUN::ECS::Instance
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      action: '{{ action }}'
      whetherCreateSnapshot: '{{ whetherCreateSnapshot }}'
      retentionDays: '{{ retentionDays }}'
      rebootIfNeed: '{{ rebootIfNeed }}'
      timeout: '{{ timeout }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'
      Outputs:
        commandOutputs:
          AggregateType: Fn::ListJoin
          AggregateField: commandOutput
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: commandOutput
  - Name: applyPatchBaselineOnManagedInstance
    Description:
      en: Apply patch baseline on ECS managed instance
      zh-cn: the description in Chinese
    Action: ACS::ECS::ApplyPatchBaselineOnMangedInstance
    When:
      Fn::Equals:
        - '{{ resourceType }}'
        - ALIYUN::ECS::ManagedInstance
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      action: '{{ action }}'
      timeout: '{{ timeout }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'
      Outputs:
        commandOutputs:
          AggregateType: Fn::ListJoin
          AggregateField: commandOutput
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: commandOutput
  - Name: applyPatchBaselineOnECDInstance
    Description:
      en: Apply patch baseline on ECD instance
      zh-cn: the description in Chinese
    Action: ACS::ECD::ApplyPatchBaseline
    When:
      Fn::Equals:
        - '{{ resourceType }}'
        - ALIYUN::ECD::Desktop
    Properties:
      regionId: '{{ regionId }}'
      desktopId: '{{ ACS::TaskLoopItem }}'
      action: '{{ action }}'
      rebootIfNeed: '{{ rebootIfNeed }}'
      whetherCreateSnapshot: '{{ whetherCreateSnapshot }}'
      timeout: '{{ timeout }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'
      Outputs:
        commandOutputs:
          AggregateType: Fn::ListJoin
          AggregateField: commandOutput
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: commandOutput
Outputs:
  commandOutputs:
    Type: List
    Value: '{{ applyPatchBaseline.commandOutputs }}'