模板名称
ACS-ECS-BulkyRunCommandInSLBDefaultServerGroup 批量在SLB默认服务组内的ECS实例上运行命令
模板描述
批量在SLB默认服务组内的ECS实例上运行命令
模板类型
自动化
所有者
Alibaba Cloud
输入参数
参数名称  | 描述  | 类型  | 是否必填  | 默认值  | 约束  | 
loadBalancerId  | 负载均衡实例ID  | String  | 是  | ||
commandType  | 云助手命令类型  | String  | 否  | RunShellScript  | |
commandContent  | 在ECS实例中执行的云助手命令  | String  | 否  | echo hello  | |
rateControl  | 任务执行的并发比率  | Json  | 否  | {‘Mode’: ‘Concurrency’, ‘MaxErrors’: 0, ‘Concurrency’: 1}  | |
OOSAssumeRole  | OOS扮演的RAM角色  | String  | 否  | “”  | 
输出参数
参数名称  | 描述  | 类型  | 
commandOutputs  | List  | 
执行此模板需要的权限策略
{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "slb:DescribeLoadBalancerAttribute",
                "slb:SetBackendServers"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}
详情
ACS-ECS-BulkyRunCommandInSLBDefaultServerGroup详情
模板内容
FormatVersion: OOS-2019-06-01
Description:
  en: Bulky run command on ECS instances of  default server group
  zh-cn: 批量在SLB默认服务组内的ECS实例上运行命令
  name-en: ACS-ECS-BulkyRunCommandInSLBDefaultServerGroup
  name-zh-cn: 批量在SLB默认服务组内的ECS实例上运行命令
  categories:
    - slb_management
Parameters:
  loadBalancerId:
    Label:
      en: LoadBalancerId
      zh-cn: 负载均衡实例ID
    Type: String
  commandType:
    Label:
      en: CommandType
      zh-cn: 云助手命令类型
    Type: String
    AllowedValues:
      - RunBatScript
      - RunPowerShellScript
      - RunShellScript
    Default: RunShellScript
  commandContent:
    Label:
      en: CommandContent
      zh-cn: 在ECS实例中执行的云助手命令
    Type: String
    AssociationProperty: Code
    Default: echo hello
  rateControl:
    Label:
      en: RateControl
      zh-cn: 任务执行的并发比率
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 1
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: OOS扮演的RAM角色
    Type: String
    Default: ''
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: describeLoadBalancerAttribute
    Action: ACS::ExecuteApi
    Description:
      en: Views loadbalancer attribute
      zh-cn: 获取负载均衡默认服务组属性
    Properties:
      Service: SLB
      API: DescribeLoadBalancerAttribute
      Parameters:
        LoadBalancerId: '{{ loadBalancerId }}'
    Outputs:
      BackendServers:
        Type: List
        ValueSelector: BackendServers.BackendServer[]
      port:
        Type: Number
        ValueSelector: ListenerPorts.ListenerPort[]
  - Name: runCommand
    Action: ACS::ECS::ElegantRunCommandInSLBDefaultServerGroup
    Description:
      en: Execute cloud assistant command
      zh-cn: 执行云助手命令
    Properties:
      loadBalancerId: '{{ LoadBalancerId }}'
      commandContent: '{{ commandContent }}'
      commandType: '{{ commandType }}'
      serverId:
        'Fn::Select':
          - ServerId
          - '{{ ACS::TaskLoopItem }}'
      weight:
        'Fn::Select':
          - Weight
          - '{{ ACS::TaskLoopItem }}'
      type:
        'Fn::Select':
          - Type
          - '{{ ACS::TaskLoopItem }}'
      port: '{{ describeLoadBalancerAttribute.port }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ describeLoadBalancerAttribute.BackendServers }}'
      Outputs:
        commandOutputs:
          AggregateType: Fn::ListJoin
          AggregateField: commandOutput
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: commandOutput
Outputs:
  commandOutputs:
    Type: List
    Value: '{{ runCommand.commandOutputs }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - loadBalancerId
          - commandType
          - commandContent
        Label:
          default:
            zh-cn: 设置参数
            en: Configure Parameters
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: 高级选项
            en: Control该文章对您有帮助吗?