全部产品
Search
文档中心

系统运维管理:ACS-ECS-BulkyApplyPatchBaseline

更新时间:Sep 05, 2024

模板名称

ACS-ECS-BulkyApplyPatchBaseline 批量在ECS实例中配置补丁基线

立即执行

模板描述

批量在ECS实例中配置补丁基线

模板类型

自动化

所有者

Alibaba Cloud

输入参数

参数名称

描述

类型

是否必填

默认值

约束

targets

目标实例

Json

regionId

地域ID

String

{{ ACS::RegionId }}

resourceType

资源类型

String

ALIYUN::ECS::Instance

action

配置补丁基线的方式

String

install

whetherCreateSnapshot

是否为系统盘创建快照

Boolean

False

retentionDays

快照保留天数

Number

7

rebootIfNeed

是否重启

Boolean

False

rateControl

任务执行的并发比率

Json

{‘Mode’: ‘Concurrency’, ‘MaxErrors’: 0, ‘Concurrency’: 10}

OOSAssumeRole

OOS扮演的RAM角色

String

“”

timeout

ECS实例中执行命令的超时时间

Number

7200

输出参数

参数名称

描述

类型

commandOutput

String

执行此模板需要的权限策略

{
    "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"
        }
    ]
}

详情

ACS-ECS-BulkyApplyPatchBaseline详情

模板内容

FormatVersion: OOS-2019-06-01
Description:
  name-en: ACS-ECS-BulkyApplyPatchBaseline
  name-zh-cn: 批量在ECS实例中配置补丁基线
  en: Bulky apply patch baseline on ECS instance
  zh-cn: 批量在ECS实例中配置补丁基线
Parameters:
  regionId:
    Label:
      en: RegionId
      zh-cn: 地域ID
    AssociationProperty: RegionId
    Type: String
    Default: '{{ ACS::RegionId }}'
  resourceType:
    Type: String
    Label:
      en: ResourceType
      zh-cn: 资源类型
    AssociationPropertyMetadata:
      LocaleKey: TargetResourceType
    AllowedValues:
      - ALIYUN::ECS::Instance
      - ALIYUN::ECS::ManagedInstance
      - ALIYUN::ECD::Desktop
    Default: ALIYUN::ECS::Instance
  targets:
    Label:
      en: TargetInstance
      zh-cn: 目标实例
    Type: Json
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: resourceType
      RegionId: regionId
  action:
    Label:
      en: Action
      zh-cn: 配置补丁基线的方式
    Type: String
    AllowedValues:
      - install
      - scan
    Default: install
    AssociationPropertyMetadata:
      LocaleKey: OOSPatchExecuteType
  whetherCreateSnapshot:
    Label:
      en: WhetherCreateSnapshot
      zh-cn: 是否为系统盘创建快照
    Type: Boolean
    Default: false
    AssociationPropertyMetadata:
      Visible:
        Condition:
            Fn::Equals:
              - '${action}'
              - install
  retentionDays:
    Label:
      en: RetentionDays
      zh-cn: 快照保留天数
    Type: Number
    MinValue: 1
    MaxValue: 65536
    Default: 7
    AssociationPropertyMetadata:
      Visible:
        Condition:
            Fn::Equals:
              - '${whetherCreateSnapshot}'
              - true
  rebootIfNeed:
    Label:
      en: RebootIfNeed
      zh-cn: 是否重启
    Type: Boolean
    Default: false
    AssociationPropertyMetadata:
      Visible:
        Condition:
            'Fn::Equals':
              - '${action}'
              - install
  rateControl:
    Label:
      en: RateControl
      zh-cn: 任务执行的并发比率
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: ''
  timeout:
    Label:
      en: Timeout
      zh-cn: ECS实例中执行命令的超时时间
    Type: Number
    Default: 7200
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Views the ECS instances
      zh-cn: 获取ECS实例
    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: 在ECS实例中配置补丁基线
    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: 在ECS托管实例中配置补丁基线
    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: 在ECD实例中配置补丁基线
    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:
  commandOutput:
    Type: String
    Value:
      Fn::If:
        - Fn::Equals:
            - '{{ resourceType }}'
            - ALIYUN::ECS::Instance
        - '{{ applyPatchBaseline.commandOutputs }}'
        - Fn::If:
            - Fn::Equals:
                - '{{ resourceType }}'
                - ALIYUN::ECS::ManagedInstance
            - '{{ applyPatchBaselineOnManagedInstance.commandOutputs }}'
            - '{{ applyPatchBaselineOnECDInstance.commandOutputs }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - action
          - whetherCreateSnapshot
          - retentionDays
          - rebootIfNeed
          - timeout
        Label:
          default:
            zh-cn: 配置参数
            en: Configure Parameters
      - Parameters:
          - regionId
          - resourceType
          - targets
        Label:
          default:
            zh-cn: 选择实例
            en: Select Instances
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 高级选项
            en: Control Options