azure_rm_loadbalancer – Manage Azure load balancers

New in version 2.4.

Synopsis

  • Create, update and delete Azure load balancers

Requirements

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

  • python >= 2.7
  • azure >= 2.0.0

Parameters

Parameter Choices/Defaults Comments
ad_user
string
Active Directory username. Use when authenticating with an Active Directory user rather than service principal.
adfs_authority_url
string
added in 2.6
Azure AD authority url. Use when authenticating with Username/password, and has your own ADFS authority.
api_profile
string
added in 2.5
Default:
"latest"
Selects an API profile to use when communicating with Azure services. Default value of latest is appropriate for public clouds; future values will allow use with Azure Stack.
append_tags
boolean
    Choices:
  • no
  • yes
Use to control if tags field is canonical or just appends to existing tags.
When canonical, any tags not found in the tags parameter will be removed from the object's metadata.
auth_source
string
added in 2.5
    Choices:
  • auto
  • cli
  • credential_file
  • env
  • msi
Controls the source of the credentials to use for authentication.
If not specified, ANSIBLE_AZURE_AUTH_SOURCE environment variable will be used and default to auto if variable is not defined.
auto will follow the default precedence of module parameters -> environment variables -> default profile in credential file ~/.azure/credentials.
When set to cli, the credentials will be sources from the default Azure CLI profile.
Can also be set via the ANSIBLE_AZURE_AUTH_SOURCE environment variable.
When set to msi, the host machine must be an azure resource with an enabled MSI extension. subscription_id or the environment variable AZURE_SUBSCRIPTION_ID can be used to identify the subscription ID if the resource is granted access to more than one subscription, otherwise the first subscription is chosen.
The msi was added in Ansible 2.6.
backend_address_pools
-
added in 2.5
List of backend address pools
name
- / required
Name of the backend address pool.
backend_port
-
(deprecated) Backend port that will be exposed for the load balancer.
This option has been deprecated, and will be removed in 2.9. Use load_balancing_rules instead.
cert_validation_mode
string
added in 2.5
    Choices:
  • ignore
  • validate
Controls the certificate validation behavior for Azure endpoints. By default, all modules will validate the server certificate, but when an HTTPS proxy is in use, or against Azure Stack, it may be necessary to disable this behavior by passing ignore. Can also be set via credential file profile or the AZURE_CERT_VALIDATION environment variable.
client_id
string
Azure client ID. Use when authenticating with a Service Principal.
cloud_environment
string
added in 2.4
Default:
"AzureCloud"
For cloud environments other than the US public cloud, the environment name (as defined by Azure Python SDK, eg, AzureChinaCloud, AzureUSGovernment), or a metadata discovery endpoint URL (required for Azure Stack). Can also be set via credential file profile or the AZURE_CLOUD_ENVIRONMENT environment variable.
frontend_ip_configurations
-
added in 2.5
List of frontend IPs to be used
name
- / required
Name of the frontend ip configuration.
private_ip_address
-
added in 2.6
The reference of the Public IP resource.
private_ip_allocation_method
-
added in 2.6
    Choices:
  • Static
  • Dynamic
The Private IP allocation method.
public_ip_address
-
Name of an existing public IP address object in the current resource group to associate with the security group.
subnet
-
added in 2.6
The reference of the subnet resource.
Should be an existing subnet's resource id.
frontend_port
-
(deprecated) Frontend port that will be exposed for the load balancer.
This option has been deprecated, and will be removed in 2.9. Use load_balancing_rules instead.
idle_timeout
-
Default:
4
(deprecated) Timeout for TCP idle connection in minutes.
This option has been deprecated, and will be removed in 2.9. Use load_balancing_rules instead.
inbound_nat_pools
-
added in 2.5
Defines an external port range for inbound NAT to a single backend port on NICs associated with a load balancer.
Inbound NAT rules are created automatically for each NIC associated with the Load Balancer using an external port from this range.
Defining an Inbound NAT pool on your Load Balancer is mutually exclusive with defining inbound Nat rules.
Inbound NAT pools are referenced from virtual machine scale sets.
NICs that are associated with individual virtual machines cannot reference an inbound NAT pool.
They have to reference individual inbound NAT rules.
backend_port
-
The port used for internal connections on the endpoint.
Acceptable values are between 1 and 65535.
frontend_ip_configuration_name
- / required
A reference to frontend IP addresses.
frontend_port_range_end
- / required
The last port in the range of external ports that will be used to provide inbound NAT to NICs associated with the load balancer.
Acceptable values range between 1 and 65535.
frontend_port_range_start
- / required
The first port in the range of external ports that will be used to provide inbound NAT to NICs associated with the load balancer.
Acceptable values range between 1 and 65534.
name
- / required
Name of the inbound NAT pool.
protocol
-
    Choices:
  • Tcp
  • Udp
  • All
IP protocol for the NAT pool
inbound_nat_rules
-
added in 2.8
Collection of inbound NAT Rules used by a load balancer.
Defining inbound NAT rules on your load balancer is mutually exclusive with defining an inbound NAT pool.
Inbound NAT pools are referenced from virtual machine scale sets.
NICs that are associated with individual virtual machines cannot reference an Inbound NAT pool.
They have to reference individual inbound NAT rules.
backend_port
-
The port used for internal connections on the endpoint.
Acceptable values are between 0 and 65535.
Note that value 0 enables "Any Port"
enable_floating_ip
-
Configures a virtual machine's endpoint for the floating IP capability required to configure a SQL AlwaysOn Availability Group.
This setting is required when using the SQL AlwaysOn Availability Groups in SQL server.
This setting can't be changed after you create the endpoint.
enable_tcp_reset
-
Receive bidirectional TCP Reset on TCP flow idle timeout or unexpected connection termination.
This element is only used when the protocol is set to Tcp.
frontend_ip_configuration
- / required
A reference to frontend IP addresses.
frontend_port
-
The port for the external endpoint.
Frontend port numbers must be unique across all rules within the load balancer.
Acceptable values are between 0 and 65534.
Note that value 0 enables "Any Port"
idle_timeout
-
The timeout for the TCP idle connection.
The value can be set between 4 and 30 minutes.
The default value is 4 minutes.
This element is only used when the protocol is set to TCP.
name
- / required
name of the inbound nat rule.
protocol
-
    Choices:
  • Tcp
  • Udp
  • All
IP protocol for the inbound nat rule.
load_balancing_rules
-
added in 2.5
Object collection representing the load balancing rules Gets the provisioning.
backend_address_pool
- / required
A reference to a pool of DIPs. Inbound traffic is randomly load balanced across IPs in the backend IPs.
backend_port
-
The port used for internal connections on the endpoint.
Acceptable values are between 0 and 65535.
Note that value 0 enables "Any Port"
enable_floating_ip
-
Configures SNAT for the VMs in the backend pool to use the publicIP address specified in the frontend of the load balancing rule.
frontend_ip_configuration
- / required
A reference to frontend IP addresses.
frontend_port
-
The port for the external endpoint.
Frontend port numbers must be unique across all rules within the load balancer.
Acceptable values are between 0 and 65534.
Note that value 0 enables "Any Port"
idle_timeout
-
The timeout for the TCP idle connection.
The value can be set between 4 and 30 minutes.
The default value is 4 minutes.
This element is only used when the protocol is set to TCP.
load_distribution
-
    Choices:
  • Default
  • SourceIP
  • SourceIPProtocol
The session persistence policy for this rule; Default is no persistence.
name
- / required
name of the load balancing rule.
probe
- / required
The name of the load balancer probe this rule should use for health checks.
protocol
-
    Choices:
  • Tcp
  • Udp
  • All
IP protocol for the load balancing rule.
load_distribution
-
    Choices:
  • Default
  • SourceIP
  • SourceIPProtocol
(deprecated) The type of load distribution that the load balancer will employ.
This option has been deprecated, and will be removed in 2.9. Use load_balancing_rules instead.
location
-
Valid azure location. Defaults to location of the resource group.
name
- / required
Name of the load balancer.
natpool_backend_port
-
(deprecated) Backend port used by the NAT pool.
This option has been deprecated, and will be removed in 2.9. Use inbound_nat_pools instead.
natpool_frontend_port_end
-
(deprecated) End of the port range for a NAT pool.
This option has been deprecated, and will be removed in 2.9. Use inbound_nat_pools instead.
natpool_frontend_port_start
-
(deprecated) Start of the port range for a NAT pool.
This option has been deprecated, and will be removed in 2.9. Use inbound_nat_pools instead.
natpool_protocol
-
(deprecated) The protocol for the NAT pool.
This option has been deprecated, and will be removed in 2.9. Use inbound_nat_pools instead.
password
-
Active Directory user password. Use when authenticating with an Active Directory user rather than service principal.
probe_fail_count
-
Default:
3
(deprecated) The amount of probe failures for the load balancer to make a health determination.
This option has been deprecated, and will be removed in 2.9. Use probes instead.
probe_interval
-
Default:
15
(deprecated) Time (in seconds) between endpoint health probes.
This option has been deprecated, and will be removed in 2.9. Use probes instead.
probe_port
-
(deprecated) The port that the health probe will use.
This option has been deprecated, and will be removed in 2.9. Use probes instead.
probe_protocol
-
    Choices:
  • Tcp
  • Http
(deprecated) The protocol to use for the health probe.
This option has been deprecated, and will be removed in 2.9. Use probes instead.
probe_request_path
-
(deprecated) The URL that an HTTP probe will use (only relevant if probe_protocol is set to Http).
This option has been deprecated, and will be removed in 2.9. Use probes instead.
probes
-
added in 2.5
List of probe definitions used to check endpoint health.
fail_count
-
Default:
3
The number of probes where if no response, will result in stopping further traffic from being delivered to the endpoint.
This values allows endpoints to be taken out of rotation faster or slower than the typical times used in Azure.

aliases: number_of_probes
interval
-
Default:
15
The interval, in seconds, for how frequently to probe the endpoint for health status.
Slightly less than half the allocated timeout period, which allows two full probes before taking the instance out of rotation.
The default value is 15, the minimum value is 5.
name
- / required
Name of the probe.
port
- / required
Probe port for communicating the probe. Possible values range from 1 to 65535, inclusive.
protocol
-
    Choices:
  • Tcp
  • Http
The protocol of the end point to be probed.
If 'Tcp' is specified, a received ACK is required for the probe to be successful.
If 'Http' is specified, a 200 OK response from the specified URL is required for the probe to be successful.
request_path
-
The URI used for requesting health status from the VM.
Path is required if a protocol is set to http. Otherwise, it is not allowed.
profile
string
Security profile found in ~/.azure/credentials file.
protocol
-
    Choices:
  • Tcp
  • Udp
(deprecated) The protocol (TCP or UDP) that the load balancer will use.
This option has been deprecated, and will be removed in 2.9. Use load_balancing_rules instead.
public_ip_address_name
-
(deprecated) Name of an existing public IP address object to associate with the security group.
This option has been deprecated, and will be removed in 2.9. Use frontend_ip_configurations instead.

aliases: public_ip_address, public_ip_name, public_ip
resource_group
- / required
Name of a resource group where the load balancer exists or will be created.
secret
string
Azure client secret. Use when authenticating with a Service Principal.
sku
-
added in 2.6
    Choices:
  • Basic
  • Standard
The load balancer SKU.
state
-
    Choices:
  • absent
  • present
Assert the state of the load balancer. Use present to create/update a load balancer, or absent to delete one.
subscription_id
string
Your Azure subscription Id.
tags
dictionary
Dictionary of string:string pairs to assign as metadata to the object.
Metadata tags on the object will be updated with any provided values.
To remove tags set append_tags option to false.
tenant
string
Azure tenant ID. Use when authenticating with a Service Principal.

Notes

Note

  • For authentication with Azure you can pass parameters, set environment variables, use a profile stored in ~/.azure/credentials, or log in before you run your tasks or playbook with az login.
  • Authentication is also possible using a service principal or Active Directory user.
  • To authenticate via service principal, pass subscription_id, client_id, secret and tenant or set environment variables AZURE_SUBSCRIPTION_ID, AZURE_CLIENT_ID, AZURE_SECRET and AZURE_TENANT.
  • To authenticate via Active Directory user, pass ad_user and password, or set AZURE_AD_USER and AZURE_PASSWORD in the environment.
  • Alternatively, credentials can be stored in ~/.azure/credentials. This is an ini file containing a [default] section and the following keys: subscription_id, client_id, secret and tenant or subscription_id, ad_user and password. It is also possible to add additional profiles. Specify the profile by passing profile or setting AZURE_PROFILE in the environment.

See Also

See also

Sign in with Azure CLI
How to authenticate using the az login command.

Examples

- name: create load balancer
  azure_rm_loadbalancer:
    resource_group: myResourceGroup
    name: testloadbalancer1
    frontend_ip_configurations:
      - name: frontendipconf0
        public_ip_address: testpip
    backend_address_pools:
      - name: backendaddrpool0
    probes:
      - name: prob0
        port: 80
    inbound_nat_pools:
      - name: inboundnatpool0
        frontend_ip_configuration_name: frontendipconf0
        protocol: Tcp
        frontend_port_range_start: 80
        frontend_port_range_end: 81
        backend_port: 8080
    load_balancing_rules:
      - name: lbrbalancingrule0
        frontend_ip_configuration: frontendipconf0
        backend_address_pool: backendaddrpool0
        frontend_port: 80
        backend_port: 80
        probe: prob0
    inbound_nat_rules:
      - name: inboundnatrule0
        backend_port: 8080
        protocol: Tcp
        frontend_port: 8080
        frontend_ip_configuration: frontendipconf0

Return Values

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

Key Returned Description
changed
boolean
always
Whether or not the resource has changed

state
dictionary
always
Current state of the load balancer



Status

Authors

  • Thomas Stringer (@trstringer)
  • Yuwei Zhou (@yuwzho)

Hint

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

© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.8/modules/azure_rm_loadbalancer_module.html