community.general.oneandone_load_balancer – Configure 1&1 load balancer.

Note

This plugin is part of the community.general collection.

To install it use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.oneandone_load_balancer.

Synopsis

  • Create, remove, update load balancers. This module has a dependency on 1and1 >= 1.0

Requirements

The below requirements are needed on the host that executes this module.

  • 1and1

  • python >= 2.6

Parameters

Parameter Choices/Defaults Comments
add_rules
string
A list of rules that will be added to an existing load balancer. It is syntax is the same as the one used for rules parameter. Used in combination with update state.
add_server_ips
string
A list of server identifiers (id or name) to be assigned to a load balancer. Used in combination with update state.
api_url
string
Custom API URL. Overrides the ONEANDONE_API_URL environment variable.
auth_token
string / required
Authenticating API token provided by 1&1.
datacenter
string
    Choices:
  • US ←
  • ES
  • DE
  • GB
ID or country code of the datacenter where the load balancer will be created.
description
string
Description of the load balancer. maxLength=256
health_check_interval
string / required
Health check period in seconds. minimum=5, maximum=300, multipleOf=1
health_check_parse
string
Regular expression to check. Required for HTTP health check. maxLength=64
health_check_path
string
Url to call for checking. Required for HTTP health check. maxLength=1000
health_check_test
string / required
    Choices:
  • NONE
  • TCP
  • HTTP
  • ICMP
Type of the health check. At the moment, HTTP is not allowed.
load_balancer
string / required
The identifier (id or name) of the load balancer used with update state.
method
string / required
    Choices:
  • ROUND_ROBIN
  • LEAST_CONNECTIONS
Balancing procedure.
name
string / required
Load balancer name used with present state. Used as identifier (id or name) when used with absent state. maxLength=128
persistence
boolean / required
    Choices:
  • no
  • yes
Persistence.
persistence_time
string / required
Persistence time in seconds. Required if persistence is enabled. minimum=30, maximum=1200, multipleOf=1
remove_rules
string
A list of rule ids that will be removed from an existing load balancer. Used in combination with update state.
remove_server_ips
string
A list of server IP ids to be unassigned from a load balancer. Used in combination with update state.
rules
string / required
A list of rule objects that will be set for the load balancer. Each rule must contain protocol, port_balancer, and port_server parameters, in addition to source parameter, which is optional.
state
string
    Choices:
  • present ←
  • absent
  • update
Define a load balancer state to create, remove, or update.
wait
boolean
    Choices:
  • no
  • yes ←
wait for the instance to be in state 'running' before returning
wait_interval
string
Default:
5
Defines the number of seconds to wait when using the _wait_for methods
wait_timeout
string
Default:
600
how long before wait gives up, in seconds

Examples

- 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

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
load_balancer
dictionary
always
Information about the load balancer that was processed

Sample:
{"id": "92B74394A397ECC3359825C1656D67A6", "name": "Default Balancer"}


Authors

  • Amel Ajdinovic (@aajdinov)

  • Ethan Devenport (@edevenport)