Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter zones to azure_rm_loadbalancer #801

Merged
merged 1 commit into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 41 additions & 11 deletions plugins/modules/azure_rm_loadbalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@
description:
- The reference of the subnet resource.
- Should be an existing subnet's resource id.
zones:
description:
- list of availability zones denoting the IP allocated for the resource needs to come from.
- This must be specified I(sku=Standard) and I(subnet) when setting zones.
type: list
elements: str

backend_address_pools:
description:
- List of backend address pools.
Expand Down Expand Up @@ -419,6 +426,10 @@
),
subnet=dict(
type='str'
),
zones=dict(
type='list',
elements='str'
)
)

Expand Down Expand Up @@ -770,17 +781,36 @@ def exec_module(self, **kwargs):
)] if self.protocol else None

# create new load balancer structure early, so it can be easily compared
frontend_ip_configurations_param = [self.network_models.FrontendIPConfiguration(
name=item.get('name'),
public_ip_address=self.get_public_ip_address_instance(item.get('public_ip_address')) if item.get('public_ip_address') else None,
private_ip_address=item.get('private_ip_address'),
private_ip_allocation_method=item.get('private_ip_allocation_method'),
subnet=self.network_models.Subnet(
id=item.get('subnet'),
private_endpoint_network_policies=None,
private_link_service_network_policies=None
) if item.get('subnet') else None
) for item in self.frontend_ip_configurations] if self.frontend_ip_configurations else None
if not load_balancer:
frontend_ip_configurations_param = [self.network_models.FrontendIPConfiguration(
name=item.get('name'),
public_ip_address=self.get_public_ip_address_instance(item.get('public_ip_address')) if item.get('public_ip_address') else None,
private_ip_address=item.get('private_ip_address'),
private_ip_allocation_method=item.get('private_ip_allocation_method'),
zones=item.get('zones'),
subnet=self.network_models.Subnet(
id=item.get('subnet'),
private_endpoint_network_policies=None,
private_link_service_network_policies=None
) if item.get('subnet') else None
) for item in self.frontend_ip_configurations] if self.frontend_ip_configurations else None
else:
old_front = load_balancer.frontend_ip_configurations
new_front = self.frontend_ip_configurations
frontend_ip_configurations_param = [self.network_models.FrontendIPConfiguration(
name=new_front[index].get('name'),
public_ip_address=self.get_public_ip_address_instance(
new_front[index].get('public_ip_address')
) if new_front[index].get('public_ip_address') else None,
private_ip_address=new_front[index].get('private_ip_address'),
private_ip_allocation_method=new_front[index].get('private_ip_allocation_method'),
zones=new_front[index].get('zones') if new_front[index].get('zones') else old_front[index].zones,
subnet=self.network_models.Subnet(
id=new_front[index].get('subnet'),
private_endpoint_network_policies=None,
private_link_service_network_policies=None
) if new_front[index].get('subnet') else None
) for index in range(len(new_front))] if new_front else None

backend_address_pools_param = [self.network_models.BackendAddressPool(
name=item.get('name')
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/azure_rm_loadbalancer_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
myAzureResourceGroup/providers/Microsoft.Network/publicIPAddresses/testpip"
}
},
"zones": ["1", "2", "3"],
"type": "Microsoft.Network/loadBalancers/frontendIPConfigurations"
}
],
Expand Down
12 changes: 10 additions & 2 deletions tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@

- name: assert complex load balancer created
assert:
that: output.changed
that:
- output.changed

- name: delete load balancer
azure_rm_loadbalancer:
Expand Down Expand Up @@ -263,11 +264,16 @@
azure_rm_loadbalancer:
resource_group: '{{ resource_group }}'
name: "{{ lbname_d }}"
sku: Standard
frontend_ip_configurations:
- name: frontendipconf0
private_ip_address: 10.10.0.10
private_ip_allocation_method: Static
subnet: "{{ subnet.state.id }}"
zones:
- 1
- 2
- 3
backend_address_pools:
- name: backendaddrpool0
probes:
Expand All @@ -291,7 +297,9 @@

- name: assert complex load balancer created
assert:
that: output.changed
that:
- output.changed
- output.state.frontend_ip_configurations[0].zones | length == 3

- name: delete load balancer
azure_rm_loadbalancer:
Expand Down