# oneandone_load_balancer – Configure 1&1 load balancer

New in version 2.5.

- Synopsis
- Requirements
- Parameters
- Examples
- Return Values
- Status

## 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 - |  | 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 - |  | A list of server identifiers (id or name) to be assigned to a load balancer. Used in combination with update state.
api_url - |  | Custom API URL. Overrides the ONEANDONE_API_URL environement variable.
auth_token - / required |  | Authenticating API token provided by 1&1.

datacenter
-

Choices:
- US ←
- ES
- DE
- GB

ID or country code of the datacenter where the load balancer will be created.

description - |  | Description of the load balancer. maxLength=256
health_check_interval - / required |  | Health check period in seconds. minimum=5, maximum=300, multipleOf=1
health_check_parse - |  | Regular expression to check. Required for HTTP health check. maxLength=64
health_check_path - |  | Url to call for checking. Required for HTTP health check. maxLength=1000

health_check_test
- / required

Choices:
- NONE
- TCP
- HTTP
- ICMP

Type of the health check. At the moment, HTTP is not allowed.

load_balancer - / required |  | The identifier (id or name) of the load balancer used with update state.

method
- / required

Choices:
- ROUND_ROBIN
- LEAST_CONNECTIONS

Balancing procedure.

name - / 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 - / required |  | Persistence time in seconds. Required if persistence is enabled. minimum=30, maximum=1200, multipleOf=1
remove_rules - |  | A list of rule ids that will be removed from an existing load balancer. Used in combination with update state.
remove_server_ips - |  | A list of server IP ids to be unassigned from a load balancer. Used in combination with update state.
rules - / 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
-

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 - | Default: 5 | Defines the number of seconds to wait when using the _wait_for methods
wait_timeout - | Default: 600 | how long before wait gives up, in seconds

## Examples

    # Provisioning example. Create and destroy a load balancer.

    - 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

    - oneandone_load_balancer:
        auth_token: oneandone_private_api_key
        name: ansible load balancer
        wait: true
        wait_timeout: 500
        state: absent

    # Update a load balancer.

    - 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

    # Add server to a load balancer.

    - 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

    # Remove server from a load balancer.

    - 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

    # Add rules to a load balancer.

    - 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

    # Remove rules from a load balancer.

    - 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"}

## Status

- This module is not guaranteed to have a backwards compatible interface. [preview]
- This module is maintained by the Ansible Community. [community]

### Authors

- Amel Ajdinovic (@aajdinov)
- Ethan Devenport (@edevenport)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.