hetzner.hcloud.load_balancer_target 模块 – 管理 Hetzner Cloud 负载均衡器目标
注意
此模块是 hetzner.hcloud 集合(版本 4.2.2)的一部分。
如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install hetzner.hcloud。您需要进一步的要求才能使用此模块,请参阅 要求 了解详细信息。
要在 playbook 中使用它,请指定:hetzner.hcloud.load_balancer_target。
hetzner.hcloud 0.1.0 中的新增功能
概要
- 创建和删除 Hetzner Cloud 负载均衡器目标 
别名:hcloud_load_balancer_target
要求
在执行此模块的主机上需要以下要求。
- python-dateutil >= 2.7.5 
- requests >=2.20 
参数
| 参数 | 注释 | 
|---|---|
| Hetzner Cloud 的 API 端点。 您还可以通过使用  默认值:  | |
| Hetzner Cloud 的 API 令牌。 您还可以通过使用  | |
| 来自 Hetzner 专用服务器的 IP,需要属于与项目相同的用户。 如果 type 为 ip,则为必需 | |
| 将用于动态确定目标的标签选择器 如果 type 为 label_selector,则为必需 | |
| Hetzner Cloud 负载均衡器的名称或 ID。 | |
| Hetzner Cloud 服务器的名称或 ID。 如果 type 为 server,则为必需 | |
| load_balancer_network 的状态。 选择 
 | |
| 目标的类型。 选择 
 | |
| 通过 Hetzner Cloud 网络路由负载均衡器的私有 IP 的流量。 负载均衡器需要连接到网络。请参阅 hetzner.hcloud.load_balancer_network 选择 
 | 
另请参阅
另请参阅
- Hetzner Cloud API 的文档
- Hetzner Cloud API 的完整参考。 
示例
- name: Create a server Load Balancer target
  hetzner.hcloud.load_balancer_target:
    type: server
    load_balancer: my-LoadBalancer
    server: my-server
    state: present
- name: Create a label_selector Load Balancer target
  hetzner.hcloud.load_balancer_target:
    type: label_selector
    load_balancer: my-LoadBalancer
    label_selector: application=backend
    state: present
- name: Create an IP Load Balancer target
  hetzner.hcloud.load_balancer_target:
    type: ip
    load_balancer: my-LoadBalancer
    ip: 127.0.0.1
    state: present
- name: Ensure the Load Balancer target is absent (remove if needed)
  hetzner.hcloud.load_balancer_target:
    type: server
    load_balancer: my-LoadBalancer
    server: my-server
    state: absent
返回值
常见返回值记录在此处,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 负载均衡器和网络之间的关系 返回: 始终 | |
| 专用服务器的 IP 返回: 如果 type 为 ip 示例:  | |
| 标签选择器 返回: 如果 type 为 label_selector 示例:  | |
| 负载均衡器的名称 返回: 始终 示例:  | |
| 服务器的名称 返回: 如果 type 为 server 示例:  | |
| 负载均衡器目标的类型 返回: 始终 示例:  | |
| 通过 Hetzner Cloud 网络路由负载均衡器的私有 IP 的流量。 负载均衡器需要连接到网络。请参阅 hetzner.hcloud.load_balancer_network 返回: 始终 示例:  | 
