ACS-LOG-BulkyInstallLogtail

更新时间:
复制 MD 格式

Batch-installs the Logtail agent on multiple ECS instances through OOS.

Template name

ACS-LOG-BulkyInstallLogtail

Execute Now

Template description

Installs the Logtail agent on multiple Elastic Compute Service (ECS) instances at a time.

Template type

Automated

Owner

Alibaba Cloud

Input parameters

Parameter

Description

Data type

Required

Default value

Limit

targets

The target ECS instances.

Json

Yes

regionId

The region ID.

String

No

{{ ACS::RegionId }}

action

The operation type.

String

No

install

overwrite

Whether to overwrite existing Logtail configurations on your ECS instances.

String

No

false

rateControl

The rate control settings.

Json

No

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

OOSAssumeRole

The RAM role assumed by CloudOps Orchestration Service (OOS).

String

No

""

Output parameters

Parameter

Description

Data type

commandOutput

String

Permission policy that is required to execute the template

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

References

ACS-LOG-BulkyInstallLogtail

Template content

FormatVersion: OOS-2019-06-01
Description:
  en: Use this template to install sls logtail on ecs  
  name-en: ACS-LOG-BulkyInstallLogtail  
  categories:
    - run_command
Parameters:
  regionId:
    Type: String
    Label:
      en: RegionId       
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  action:
    Type: String
    Label:
      en: Action      
    AllowedValues:
      - install
      - upgrade
      - uninstall
    Default: install
  overwrite:
    Description:
      en: If Logtail exists in the instance, choose whether to overwrite Logtail(Default no).   
    Label:
      en: Overwrite      
    Type: String
    AllowedValues:
      - 'true'
      - 'false'
    Default: 'false'
  targets:
    Type: Json
    Label:
      en: TargetInstance
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: ALIYUN::ECS::Instance
      RegionId: regionId
  rateControl:
    Label:
      en: RateControl      
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole       
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: getInstance
    Description:
      en: Views the ECS instances       
    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: invokeCommand
    Action: ACS::ECS::InvokeCommand
    Properties:
      instanceId: '{{ ACS::TaskLoopItem }}'
      regionId: '{{ regionId }}'
      parameters:
        regionid: '{{ regionId }}'
        action: '{{ action }}'
        overwrite: '{{ overwrite }}'
      commandId:
        Fn::If:
          - Fn::Equals:
              - Fn::Jq:
                  - First
                  - .|map(select(.instanceId == "{{ ACS::TaskLoopItem }}").osType)[]
                  - '{{ getInstance.instanceInfos }}'
              - linux
          - cmd-ACS-LOG-InstallLogtail-for-linux.sh
          - cmd-ACS-LOG-InstallLogtail-for-windows.ps1
    Loop:
      Items: '{{ getInstance.instanceIds }}'
      RateControl: '{{ rateControl }}'
      Outputs:
        commandOutputs:
          AggregateType: 'Fn::ListJoin'
          AggregateField: commandOutput
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: invocationOutput
Outputs:
  commandOutput:
    Type: String
    Value: '{{ invokeCommand.commandOutputs }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - action
          - overwrite
        Label:
          default:             
            en: Configure Parameters
      - Parameters:
          - regionId
          - targets
        Label:
          default:             
            en: Select Ecs Instances
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:            
            en: Control Options