全部產品
Search
文件中心

CloudOps Orchestration Service:ACS-ECS-BulkyConfigureSoftwareFromEcsAppStore

更新時間:Sep 06, 2024

模板名稱

ACS-ECS-BulkyConfigureSoftwareFromEcsAppStore 大量安裝軟體

立即執行

模板描述

使用這個模板批量的在ECS安裝軟體

模板類型

自動化

所有者

Alibaba Cloud

輸入參數

參數名稱

描述

類型

是否必填

預設值

約束

targets

目標執行個體

Json

regionId

地區ID

String

{{ ACS::RegionId }}

softwareType

軟體類型

String

Aliyun

action

操作類型

String

install

aliyunSoftwareName

阿里雲提供的軟體名稱

String

Logtail

communitySoftwareName

社區軟體名稱

String

DockerCE

installer

安裝源

String

yum

softwareName

軟體名稱

String

“”

rateControl

任務執行的並發比率

Json

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

OOSAssumeRole

OOS扮演的RAM角色

String

“”

輸出參數

參數名稱

描述

類型

commandOutput

String

執行此模板需要的權限原則

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeInstances",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

詳情

ACS-ECS-BulkyConfigureSoftwareFromEcsAppStore詳情

模板內容

FormatVersion: OOS-2019-06-01
Description:
  en: Use this template to install software on ecs
  zh-cn: 使用這個模板批量的在ECS安裝軟體
  name-en: Bulky Configure Software
  name-zh-cn: 大量安裝軟體
  categories:
    - run_command
    - application_manage
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId
      zh-cn: 地區ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  softwareType:
    Type: String
    Label:
      en: Software Type
      zh-cn: 軟體類型
    AllowedValues:
      - Aliyun
      - Community
      - SystemRepository
    Default: Aliyun
    AssociationPropertyMetadata:
      LocaleKey: SoftwareType
  action:
    Type: String
    Label:
      en: Action
      zh-cn: 操作類型
    AllowedValues:
      - install
      - uninstall
    Default: install
    AssociationPropertyMetadata:
      LocaleKey: SoftwareOperationType
  aliyunSoftwareName:
    Type: String
    Label:
      en: Aliyun Software Name
      zh-cn: 阿里雲提供的軟體名稱
    AllowedValues:
      - Logtail
      - CloudMonitorAgent
    Default: Logtail
    AssociationPropertyMetadata:
      LocaleKey: AliyunSoftwareName
      Visible:
        Condition:
          Fn::Equals:
            - ${softwareType}
            - Aliyun
  communitySoftwareName:
    Type: String
    Label:
      en: Community Software Name
      zh-cn: 社區軟體名稱
    AllowedValues:
      - DockerCE
      - BaotaPanelFree
    Default: DockerCE
    AssociationPropertyMetadata:
      LocaleKey: CommunitySoftwareName
      Visible:
        Condition:
          Fn::Equals:
            - ${softwareType}
            - Community
    Description:
      en: Baota Panel only supports to be installed on Linux. Information can be found in execution outputs.
      zh-cn: 寶塔面板僅支援Linux作業系統安裝,安裝後可以在執行輸出中查看訪問資訊。
  installer:
    Type: String
    Label:
      en: Installer
      zh-cn: 安裝源
    Default: yum
    AllowedValues:
      - apt-get
      - yum
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Equals:
            - ${softwareType}
            - SystemRepository
  softwareName:
    Type: String
    Label:
      en: Software Name
      zh-cn: 軟體名稱
    Default: ''
    AssociationPropertyMetadata:
      Visible:
        Condition:
          Fn::Equals:
            - ${softwareType}
            - SystemRepository    
  targets:
    Type: Json
    Label:
      en: TargetInstance
      zh-cn: 目標執行個體
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: ALIYUN::ECS::Instance
      RegionId: regionId
      Status: Running
  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: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Views the ECS instances
      zh-cn: 擷取ECS執行個體
    Action: ACS::SelectTargets
    Properties:
      ResourceType: ALIYUN::ECS::Instance
      RegionId: '{{ regionId }}'
      Filters:
        - '{{ targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: Instances.Instance[].InstanceId
      instanceInfos:
        Type: List
        ValueSelector: .Instances.Instance[] | {"osType":.OSType, "instanceId":.InstanceId}
  - Name: runCommand
    Action: ACS::ECS::RunCommand
    Properties:
      commandContent:
        Fn::If:
          - Fn::Equals:
              - Fn::Jq:
                  - First
                  - .|map(select(.instanceId == "{{ ACS::TaskLoopItem }}").osType)[]
                  - '{{ getInstance.instanceInfos }}'
              - linux
          - Fn::If:
              - Fn::Equals:
                  - '{{ softwareType }}'
                  - 'Aliyun'
              - Fn::If:
                  - Fn::Equals:
                      - '{{ aliyunSoftwareName }}'
                      - 'Logtail'
                  - '{{ oos:aliyun/services/oos/commands/install_logtail_for_linux }}'
                  - Fn::If:
                      - Fn::Equals:
                          - '{{ aliyunSoftwareName }}'
                          - 'CloudMonitorAgent'
                      - '{{ oos:aliyun/services/oos/commands/install_CloudMonitorAgent_for_linux }}'
                      - |-
                        echo "Aliyun software ({{ aliyunSoftwareName }}) is not supported"
                        exit 1
              - Fn::If:
                  - Fn::Equals:
                      - '{{ softwareType }}'
                      - 'Community'
                  - Fn::If:
                      - Fn::Equals:
                          - '{{ communitySoftwareName }}'
                          - 'DockerCE'
                      - '{{ oos:aliyun/services/oos/commands/install_DockerCE_for_linux }}'
                      - Fn::If:
                          - Fn::Equals:
                              - '{{ communitySoftwareName }}'
                              - 'BaotaPanelFree'
                          - '{{ oos:aliyun/services/oos/commands/install_BaoTaPanelFree_for_linux }}'
                          - |-
                            echo "Community software ({{ communitySoftwareName }}) is not supported"
                            exit 1
                  - '{{ oos:aliyun/services/oos/commands/install_from_linux_repository }}'
          - Fn::If:
              - Fn::Equals:
                  - '{{ softwareType }}'
                  - 'Aliyun'
              - Fn::If:
                  - Fn::Equals:
                      - '{{ aliyunSoftwareName }}'
                      - 'Logtail'
                  - '{{ oos:aliyun/services/oos/commands/install_logtail_for_windows }}'
                  - Fn::If:
                      - Fn::Equals:
                          - '{{ aliyunSoftwareName }}'
                          - 'CloudMonitorAgent'
                      - '{{ oos:aliyun/services/oos/commands/install_CloudMonitorAgent_for_windows }}'
                      - |-
                        echo "Aliyun software ({{ aliyunSoftwareName }}) is not supported"
                        exit 1
              - Fn::If:
                  - Fn::Equals:
                      - '{{ softwareType }}'
                      - 'Community'
                  - Fn::If:
                      - Fn::Equals:
                          - '{{ communitySoftwareName }}'
                          - 'DockerCE'
                      - '{{ oos:aliyun/services/oos/commands/install_DockerCE_for_windows }}'
                      - |-
                        echo "Community software ({{ communitySoftwareName }}) is not supported"
                        exit 1
                  - |-
                    echo "Windows system does not support SystemRepository {{ installer }}"
                    exit 1
      instanceId: '{{ ACS::TaskLoopItem }}'
      regionId: '{{ regionId }}'
      commandType:
        Fn::If:
          - Fn::Equals:
              - Fn::Jq:
                  - First
                  - .|map(select(.instanceId == "{{ ACS::TaskLoopItem }}").osType)[]
                  - '{{ getInstance.instanceInfos }}'
              - linux
          - RunShellScript
          - RunPowerShellScript
      enableParameter: true
      parameters:
        Fn::If:
          - Fn::Equals:
              - '{{softwareType }}'
              - 'SystemRepository'
          - action: '{{ action }}'
            installer: '{{ installer }}'
            softwareName: '{{ softwareName }}'
          - action: '{{ action }}'
    Loop:
      Items: '{{ getInstance.instanceIds }}'
      RateControl: '{{ rateControl }}'
      Outputs:
        commandOutputs:
          AggregateType: Fn::ListJoin
          AggregateField: commandOutput
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: invocationOutput
Outputs:
  commandOutput:
    Type: String
    Value: '{{ runCommand.commandOutputs }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - softwareType
          - aliyunSoftwareName
          - communitySoftwareName
          - installer
          - softwareName
          - action
        Label:
          default:
            zh-cn: 設定軟體參數
            en: Configure Software Parameters
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            zh-cn: 選擇執行個體
            en: Select Ecs Instances
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 進階選項
            en: Control Options