cloudscale_ch.cloud.load_balancer_pool 模块 – 管理 cloudscale.ch IaaS 服务上的负载均衡池

注意

此模块是 cloudscale_ch.cloud 集合(版本 2.4.0)的一部分。

如果您正在使用 ansible 包,您可能已经安装了这个集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install cloudscale_ch.cloud

要在 playbook 中使用它,请指定:cloudscale_ch.cloud.load_balancer_pool

cloudscale_ch.cloud 2.3.0 中的新增功能

概要

  • 在 cloudscale.ch IaaS 服务上获取、创建、更新、删除池。

参数

参数

注释

algorithm

string

传入流量在池成员之间分配的算法。

有关支持的分配算法,请参阅 [API 文档](https://www.cloudscale.ch/en/api/v1#pool-algorithms)。

api_timeout

integer

调用 cloudscale.ch API 的超时时间(以秒为单位)。

也可以在 CLOUDSCALE_API_TIMEOUT 环境变量中传递。

默认值: 45

api_token

string / 必需

cloudscale.ch API 令牌。

也可以在 CLOUDSCALE_API_TOKEN 环境变量中传递。

api_url

string

在 cloudscale_ch.cloud 1.3.0 中添加

cloudscale.ch API URL。

也可以在 CLOUDSCALE_API_URL 环境变量中传递。

默认值: "https://api.cloudscale.ch/v1"

load_balancer

string

此池的负载均衡器的 UUID。

name

string

负载均衡池的名称。

protocol

string

负载均衡器和池成员之间流量使用的协议。

有关支持的协议,请参阅 [API 文档](https://www.cloudscale.ch/en/api/v1#pool-protocols)。

state

string

负载均衡池的状态。

选择

  • "present" ← (默认)

  • "absent"

tags

dictionary

与负载均衡器关联的标签。将其设置为 {} 以清除任何标签。

uuid

string

负载均衡池的 UUID。

需要 nameuuid

注释

注意

  • 如果提供了 uuid 选项,则在池选择时,它优先于 name。这允许更新负载均衡池的名称。

  • 如果未提供 uuid 选项,则 name 用于池选择。如果存在多个具有此名称的池,则执行中止。

  • 所有操作均使用 cloudscale.ch 公共 API v1 执行。

  • 有关详细信息,请查阅完整的 API 文档:https://www.cloudscale.ch/en/api/v1

  • 所有操作都需要有效的 API 令牌。您可以使用 cloudscale.ch 控制面板在 https://control.cloudscale.ch 创建任意数量的令牌。

示例

# Create a pool for a load balancer using registered variables
- name: Create a running load balancer
  cloudscale_ch.cloud.load_balancer:
    name: 'lb1'
    flavor: 'lb-standard'
    zone: 'lpg1'
    tags:
      project: ansible-test
      stage: production
      sla: 24-7
    api_token: xxxxxx
  register: load_balancer

- name: Create a load balancer pool
  cloudscale_ch.cloud.load_balancer_pool:
    name: 'swimming-pool'
    load_balancer: '{{ load_balancer.uuid }}'
    algorithm: 'round_robin'
    protocol: 'tcp'
    tags:
      project: ansible-test
      stage: production
      sla: 24-7
    api_token: xxxxxx
  register: load_balancer_pool

# Create a load balancer pool with algorithm: round_robin and protocol: tcp
- name: Create a load balancer pool
  cloudscale_ch.cloud.load_balancer_pool:
    name: 'cloudscale-loadbalancer-pool1'
    load_balancer: '3766c579-3012-4a85-8192-2bbb4ef85b5f'
    algorithm: 'round_robin'
    protocol: 'tcp'
    tags:
      project: ansible-test
      stage: production
      sla: 24-7
    api_token: xxxxxx

# Get load balancer pool facts by name
- name: Get facts of a load balancer pool
  cloudscale_ch.cloud.load_balancer_pool:
    name: cloudscale-loadbalancer-pool1
    api_token: xxxxxx

返回值

常见的返回值记录在此处,以下是此模块独有的字段

描述

algorithm

string

传入流量在池成员之间分配的算法

返回: 成功

示例: "round_robin"

created_at

string

负载均衡池的创建日期和时间

返回: 当 state != absent 时成功

示例: "2023-02-07T15:32:02.308041Z"

href

string

用于获取有关此负载均衡器详细信息的 API URL

返回: 当 state != absent 时成功

示例: "https://api.cloudscale.ch/v1/load-balancers/pools/"

load_balancer

list / elements=string

此池连接到的负载均衡器

返回: 当 state != absent 时成功

示例: {"href": "https://api.cloudscale.ch/v1/load-balancers/15264769-ac69-4809-a8e4-4d73f8f92496", "name": "web-lb", "uuid": "15264769-ac69-4809-a8e4-4d73f8f92496"}

name

string

负载均衡池的显示名称

返回: 成功

示例: "web-lb-pool1"

protocol

string

负载均衡器和池成员之间流量使用的协议

返回: 成功

示例: "tcp"

state

string

负载均衡池的当前状态

返回: 成功

示例: "present"

tags

dictionary

与负载均衡器关联的标签

返回: 成功

示例: {"project": "my project"}

uuid

string

此负载均衡池的唯一标识符

返回: 成功

示例: "3766c579-3012-4a85-8192-2bbb4ef85b5f"

作者

  • Gaudenz Steinlin (@gaudenz)

  • Kenneth Joss (@k-304)