community.general.oneandone_load_balancer 模块 – 配置 1&1 负载均衡器
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible 包,则可能已经安装了此集合。 它不包含在 ansible-core 中。 要检查是否已安装,请运行 ansible-galaxy collection list。
要安装它,请使用:ansible-galaxy collection install community.general。 您需要进一步的要求才能使用此模块,请参阅 要求 了解详细信息。
要在 playbook 中使用它,请指定:community.general.oneandone_load_balancer。
概要
- 创建、删除、更新负载均衡器。 此模块依赖于 1and1 >= 1.0。 
要求
执行此模块的主机上需要以下要求。
- 1and1 
参数
| 参数 | 注释 | 
|---|---|
| 要添加到现有负载均衡器的规则列表。 它的语法与 rules 参数使用的语法相同。 与 update 状态结合使用。 默认值:  | |
| 要分配给负载均衡器的服务器标识符(ID 或名称)列表。 与 update 状态结合使用。 默认值:  | |
| 自定义 API URL。 覆盖  | |
| 由 1&1 提供的身份验证 API 令牌。 | |
| 将创建负载均衡器的数据中心的 ID 或国家/地区代码。 如果未指定,则默认为  选项 
 | |
| 负载均衡器的描述。 maxLength=256 | |
| 运行状况检查周期(以秒为单位)。 minimum=5, maximum=300, multipleOf=1 | |
| 要检查的正则表达式。 HTTP 运行状况检查是必需的。 maxLength=64 | |
| 要调用的检查 URL。 HTTP 运行状况检查是必需的。 maxLength=1000 | |
| 运行状况检查的类型。 目前不允许使用 HTTP。 选项 
 | |
| 与 update 状态一起使用的负载均衡器的标识符(ID 或名称)。 | |
| 负载均衡程序。 选项 
 | |
| 与 present 状态一起使用的负载均衡器名称。 与 absent 状态一起使用时用作标识符(ID 或名称)。 maxLength=128 | |
| 持久性。 选项 
 | |
| 持久性时间(以秒为单位)。 如果启用了持久性,则为必需项。 minimum=30, maximum=1200, multipleOf=1 | |
| 将从现有负载均衡器中删除的规则 ID 列表。 与 update 状态结合使用。 默认值:  | |
| 要从负载均衡器中取消分配的服务器 IP ID 列表。 与 update 状态结合使用。 默认值:  | |
| 将为负载均衡器设置的规则对象列表。 除了可选的 source 参数外,每个规则都必须包含 protocol、port_balancer 和 port_server 参数。 默认值:  | |
| 定义要创建、删除或更新的负载均衡器状态。 选项 
 | |
| 在返回之前等待实例处于“正在运行”状态 选项 
 | |
| 定义在使用 _wait_for 方法时要等待的秒数 默认值:  | |
| 等待放弃前的等待时间,以秒为单位 默认值:  | 
属性
| 属性 | 支持 | 描述 | 
|---|---|---|
| 支持:完全 | 可以在  | |
| 支持: 无 | 在差异模式下,将返回有关已更改(或可能需要在  | 
示例
- name: Create a load balancer
  community.general.oneandone_load_balancer:
    auth_token: oneandone_private_api_key
    name: ansible load balancer
    description: Testing creation of load balancer with ansible
    health_check_test: TCP
    health_check_interval: 40
    persistence: true
    persistence_time: 1200
    method: ROUND_ROBIN
    datacenter: US
    rules:
     -
       protocol: TCP
       port_balancer: 80
       port_server: 80
       source: 0.0.0.0
    wait: true
    wait_timeout: 500
- name: Destroy a load balancer
  community.general.oneandone_load_balancer:
    auth_token: oneandone_private_api_key
    name: ansible load balancer
    wait: true
    wait_timeout: 500
    state: absent
- name: Update a load balancer
  community.general.oneandone_load_balancer:
    auth_token: oneandone_private_api_key
    load_balancer: ansible load balancer
    name: ansible load balancer updated
    description: Testing the update of a load balancer with ansible
    wait: true
    wait_timeout: 500
    state: update
- name: Add server to a load balancer
  community.general.oneandone_load_balancer:
    auth_token: oneandone_private_api_key
    load_balancer: ansible load balancer updated
    description: Adding server to a load balancer with ansible
    add_server_ips:
     - server identifier (id or name)
    wait: true
    wait_timeout: 500
    state: update
- name: Remove server from a load balancer
  community.general.oneandone_load_balancer:
    auth_token: oneandone_private_api_key
    load_balancer: ansible load balancer updated
    description: Removing server from a load balancer with ansible
    remove_server_ips:
     - B2504878540DBC5F7634EB00A07C1EBD (server's ip id)
    wait: true
    wait_timeout: 500
    state: update
- name: Add rules to a load balancer
  community.general.oneandone_load_balancer:
    auth_token: oneandone_private_api_key
    load_balancer: ansible load balancer updated
    description: Adding rules to a load balancer with ansible
    add_rules:
     -
       protocol: TCP
       port_balancer: 70
       port_server: 70
       source: 0.0.0.0
     -
       protocol: TCP
       port_balancer: 60
       port_server: 60
       source: 0.0.0.0
    wait: true
    wait_timeout: 500
    state: update
- name: Remove rules from a load balancer
  community.general.oneandone_load_balancer:
    auth_token: oneandone_private_api_key
    load_balancer: ansible load balancer updated
    description: Adding rules to a load balancer with ansible
    remove_rules:
     - rule_id #1
     - rule_id #2
     - ...
    wait: true
    wait_timeout: 500
    state: update
返回值
常见返回值记录在 此处,以下是此模块特有的字段
| 键 | 描述 | 
|---|---|
| 关于已处理的负载均衡器的信息 返回: 始终 示例:  | 
