【问题标题】:How to add load balancer to aws ecs service with ansible如何使用 ansible 将负载均衡器添加到 aws ecs 服务
【发布时间】:2019-11-25 07:55:59
【问题描述】:

我想用ansibleload balancer 添加到ecs service 模块。因此,我使用以下代码:

- name: create ECS service on VPC network
  ecs_service:
    state: present
    name: console-test-service
    cluster: new_cluster
    desired_count: 0
    network_configuration:
      subnets:
      - subnet-abcd1234
      security_groups:
      - sg-aaaa1111
      - my_security_group

现在,我想添加一个带有load_balancers 参数的负载均衡器。但是,它需要负载均衡器列表。如何添加要定义的负载均衡器名称列表?

例如:

load_balancers: 
   - name_of_my_load_balancer

返回以下错误:

提高 ParamValidationError(report=report.generate_report())\nbotocore.exceptions.ParamValidationError: 参数验证失败:\n参数类型无效 loadBalancers[0],值:name_of_my_load_balancer,类型:,有效 类型:\n"

【问题讨论】:

    标签: amazon-web-services ansible amazon-ecs amazon-elb


    【解决方案1】:

    它需要一个包含目标组 ARN、容器名称和容器端口的字典。

    - name: create ECS service on VPC network
      ecs_service:
        state: present
        name: console-test-service
        cluster: new_cluster
        desired_count: 0
        load_balancers:
          - targetGroupArn: arn:aws:elasticloadbalancing:eu-west-1:453157221:targetgroup/tg/16331647320e8a42
            containerName: laravel
            containerPort: 80
        network_configuration:
          subnets:
          - subnet-abcd1234
          security_groups:
          - sg-aaaa1111
          - my_security_group
    
    

    【讨论】:

    • Ansible 是否会在 ecs_service 任务中自动创建负载均衡器?
    • @matthewatabet 它没有
    猜你喜欢
    • 2019-05-22
    • 2021-10-12
    • 1970-01-01
    • 2016-04-05
    • 2021-07-21
    • 2021-07-02
    • 2020-10-24
    • 1970-01-01
    • 2017-01-04
    相关资源
    最近更新 更多