Skip to content

Commit

Permalink
azure_rm_loadbalancer, azure_rm_networkinterface: remove functionalit…
Browse files Browse the repository at this point in the history
…y which should have been removed for Ansible 2.9 (#1508)

As found in #65745, these two modules contain options which were supposed to be removed in Ansible 2.9.
Since the sanity check didn't find the corresponding module.deprecate() calls, no issue was created and
these deprecations were apparently forgotten.

Fixes #77
  • Loading branch information
p3ck authored May 20, 2024
1 parent 5191b94 commit 9509489
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 348 deletions.
208 changes: 0 additions & 208 deletions plugins/modules/azure_rm_loadbalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,99 +328,6 @@
- Receive bidirectional TCP Reset on TCP flow idle timeout or unexpected connection termination.
- This element is only used when I(protocol=Tcp).
type: bool
public_ip_address_name:
description:
- (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 I(frontend_ip_configurations) instead.
type: str
aliases:
- public_ip_address
- public_ip_name
- public_ip
probe_port:
description:
- (deprecated) The port that the health probe will use.
- This option has been deprecated, and will be removed in 2.9. Use I(probes) instead.
type: int
probe_protocol:
description:
- (deprecated) The protocol to use for the health probe.
- This option has been deprecated, and will be removed in 2.9. Use I(probes) instead.
type: str
choices:
- Tcp
- Http
- Https
probe_interval:
description:
- (deprecated) Time (in seconds) between endpoint health probes.
- This option has been deprecated, and will be removed in 2.9. Use I(probes) instead.
type: int
default: 15
probe_fail_count:
description:
- (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 I(probes) instead.
default: 3
type: int
probe_request_path:
description:
- (deprecated) The URL that an HTTP probe or HTTPS probe will use (only relevant if I(probe_protocol=Http) or I(probe_protocol=Https)).
- This option has been deprecated, and will be removed in 2.9. Use I(probes) instead.
type: str
protocol:
description:
- (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 I(load_balancing_rules) instead.
type: str
choices:
- Tcp
- Udp
load_distribution:
description:
- (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 I(load_balancing_rules) instead.
type: str
choices:
- Default
- SourceIP
- SourceIPProtocol
frontend_port:
description:
- (deprecated) Frontend port that will be exposed for the load balancer.
- This option has been deprecated, and will be removed in 2.9. Use I(load_balancing_rules) instead.
type: int
backend_port:
description:
- (deprecated) Backend port that will be exposed for the load balancer.
- This option has been deprecated, and will be removed in 2.9. Use I(load_balancing_rules) instead.
type: int
idle_timeout:
description:
- (deprecated) Timeout for TCP idle connection in minutes.
- This option has been deprecated, and will be removed in 2.9. Use I(load_balancing_rules) instead.
type: int
default: 4
natpool_frontend_port_start:
description:
- (deprecated) Start of the port range for a NAT pool.
- This option has been deprecated, and will be removed in 2.9. Use I(inbound_nat_pools) instead.
type: int
natpool_frontend_port_end:
description:
- (deprecated) End of the port range for a NAT pool.
- This option has been deprecated, and will be removed in 2.9. Use I(inbound_nat_pools) instead.
type: int
natpool_backend_port:
description:
- (deprecated) Backend port used by the NAT pool.
- This option has been deprecated, and will be removed in 2.9. Use I(inbound_nat_pools) instead.
type: int
natpool_protocol:
description:
- (deprecated) The protocol for the NAT pool.
- This option has been deprecated, and will be removed in 2.9. Use I(inbound_nat_pools) instead.
type: str
extends_documentation_fragment:
- azure.azcollection.azure
- azure.azcollection.azure_tags
Expand Down Expand Up @@ -710,58 +617,6 @@ def __init__(self):
type='list',
elements='dict',
options=load_balancing_rule_spec
),
public_ip_address_name=dict(
type='str',
aliases=['public_ip_address', 'public_ip_name', 'public_ip']
),
probe_port=dict(
type='int'
),
probe_protocol=dict(
type='str',
choices=['Tcp', 'Http', 'Https']
),
probe_interval=dict(
type='int',
default=15
),
probe_fail_count=dict(
type='int',
default=3
),
probe_request_path=dict(
type='str'
),
protocol=dict(
type='str',
choices=['Tcp', 'Udp']
),
load_distribution=dict(
type='str',
choices=['Default', 'SourceIP', 'SourceIPProtocol']
),
frontend_port=dict(
type='int'
),
backend_port=dict(
type='int'
),
idle_timeout=dict(
type='int',
default=4
),
natpool_frontend_port_start=dict(
type='int'
),
natpool_frontend_port_end=dict(
type='int'
),
natpool_backend_port=dict(
type='int'
),
natpool_protocol=dict(
type='str'
)
)

Expand All @@ -775,22 +630,7 @@ def __init__(self):
self.inbound_nat_rules = None
self.inbound_nat_pools = None
self.load_balancing_rules = None
self.public_ip_address_name = None
self.state = None
self.probe_port = None
self.probe_protocol = None
self.probe_interval = None
self.probe_fail_count = None
self.probe_request_path = None
self.protocol = None
self.load_distribution = None
self.frontend_port = None
self.backend_port = None
self.idle_timeout = None
self.natpool_frontend_port_start = None
self.natpool_frontend_port_end = None
self.natpool_backend_port = None
self.natpool_protocol = None
self.tags = None

self.results = dict(changed=False, state=dict())
Expand All @@ -814,54 +654,6 @@ def exec_module(self, **kwargs):
load_balancer = self.get_load_balancer()

if self.state == 'present':
# compatible parameters
is_compatible_param = not self.frontend_ip_configurations and not self.backend_address_pools and not self.probes and not self.inbound_nat_pools
is_compatible_param = is_compatible_param and not load_balancer # the instance should not be exist
is_compatible_param = is_compatible_param or self.public_ip_address_name or self.probe_protocol or self.natpool_protocol or self.protocol
if is_compatible_param:
self.deprecate('Discrete load balancer config settings are deprecated and will be removed.'
' Use frontend_ip_configurations, backend_address_pools, probes, inbound_nat_pools lists instead.', version=(2, 9))
frontend_ip_name = 'frontendip0'
backend_address_pool_name = 'backendaddrp0'
prob_name = 'prob0'
inbound_nat_pool_name = 'inboundnatp0'
lb_rule_name = 'lbr'
self.frontend_ip_configurations = [dict(
name=frontend_ip_name,
public_ip_address=self.public_ip_address_name
)]
self.backend_address_pools = [dict(
name=backend_address_pool_name
)]
self.probes = [dict(
name=prob_name,
port=self.probe_port,
protocol=self.probe_protocol,
interval=self.probe_interval,
fail_count=self.probe_fail_count,
request_path=self.probe_request_path
)] if self.probe_protocol else None
self.inbound_nat_pools = [dict(
name=inbound_nat_pool_name,
frontend_ip_configuration_name=frontend_ip_name,
protocol=self.natpool_protocol,
frontend_port_range_start=self.natpool_frontend_port_start,
frontend_port_range_end=self.natpool_frontend_port_end,
backend_port=self.natpool_backend_port
)] if self.natpool_protocol else None
self.load_balancing_rules = [dict(
name=lb_rule_name,
frontend_ip_configuration=frontend_ip_name,
backend_address_pool=backend_address_pool_name,
probe=prob_name,
protocol=self.protocol,
load_distribution=self.load_distribution,
frontend_port=self.frontend_port,
backend_port=self.backend_port,
idle_timeout=self.idle_timeout,
enable_floating_ip=False,
)] if self.protocol else None

# create new load balancer structure early, so it can be easily compared
if not load_balancer:
frontend_ip_configurations_param = [self.network_models.FrontendIPConfiguration(
Expand Down
64 changes: 4 additions & 60 deletions plugins/modules/azure_rm_networkinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,47 +79,6 @@
- Windows
- Linux
default: Linux
private_ip_address:
description:
- (Deprecate) Valid IPv4 address that falls within the specified subnet.
- This option will be deprecated in 2.9, use I(ip_configurations) instead.
type: str
private_ip_allocation_method:
description:
- (Deprecate) Whether or not the assigned IP address is permanent.
- When creating a network interface, if you specify I(private_ip_address=Static), you must provide a value for I(private_ip_address).
- You can update the allocation method to C(Static) after a dynamic private IP address has been assigned.
- This option will be deprecated in 2.9, use I(ip_configurations) instead.
default: Dynamic
type: str
choices:
- Dynamic
- Static
public_ip:
description:
- (Deprecate) When creating a network interface, if no public IP address name is provided a default public IP address will be created.
- Set to C(false) if you do not want a public IP address automatically created.
- This option will be deprecated in 2.9, use I(ip_configurations) instead.
type: bool
default: 'yes'
public_ip_address_name:
description:
- (Deprecate) Name of an existing public IP address object to associate with the security group.
- This option will be deprecated in 2.9, use I(ip_configurations) instead.
type: str
aliases:
- public_ip_address
- public_ip_name
public_ip_allocation_method:
description:
- (Deprecate) If a I(public_ip_address_name) is not provided, a default public IP address will be created.
- The allocation method determines whether or not the public IP address assigned to the network interface is permanent.
- This option will be deprecated in 2.9, use I(ip_configurations) instead.
type: str
choices:
- Dynamic
- Static
default: Dynamic
ip_configurations:
description:
- List of IP configurations. Each configuration object should include
Expand Down Expand Up @@ -323,7 +282,6 @@
virtual_network: vnet001
subnet_name: subnet001
create_with_security_group: false
public_ip: false
ip_configurations:
- name: default
primary: true
Expand Down Expand Up @@ -614,13 +572,8 @@ def __init__(self):
create_with_security_group=dict(type='bool', default=True),
security_group=dict(type='raw', aliases=['security_group_name']),
state=dict(default='present', choices=['present', 'absent']),
private_ip_address=dict(type='str'),
private_ip_allocation_method=dict(type='str', choices=['Dynamic', 'Static'], default='Dynamic'),
public_ip_address_name=dict(type='str', aliases=['public_ip_address', 'public_ip_name']),
public_ip=dict(type='bool', default=True),
subnet_name=dict(type='str', aliases=['subnet']),
virtual_network=dict(type='raw', aliases=['virtual_network_name']),
public_ip_allocation_method=dict(type='str', choices=['Dynamic', 'Static'], default='Dynamic'),
ip_configurations=dict(type='list', default=[], elements='dict', options=ip_configuration_spec),
os_type=dict(type='str', choices=['Windows', 'Linux'], default='Linux'),
open_ports=dict(type='list', elements='str'),
Expand All @@ -638,13 +591,8 @@ def __init__(self):
self.create_with_security_group = None
self.enable_accelerated_networking = None
self.security_group = None
self.private_ip_address = None
self.private_ip_allocation_method = None
self.public_ip_address_name = None
self.public_ip = None
self.subnet_name = None
self.virtual_network = None
self.public_ip_allocation_method = None
self.state = None
self.tags = None
self.os_type = None
Expand Down Expand Up @@ -703,17 +651,13 @@ def exec_module(self, **kwargs):
if len(asgs) > 0:
config['application_security_groups'] = asgs

# If ip_confiurations is not specified then provide the default
# private interface
if self.state == 'present' and not self.ip_configurations:
# construct the ip_configurations array for compatible
self.deprecate('Setting ip_configuration flatten is deprecated and will be removed.'
' Using ip_configurations list to define the ip configuration', version=(2, 9))
self.ip_configurations = [
dict(
private_ip_address=self.private_ip_address,
private_ip_allocation_method=self.private_ip_allocation_method,
public_ip_address_name=self.public_ip_address_name if self.public_ip else None,
public_ip_allocation_method=self.public_ip_allocation_method,
name='default',
private_ip_allocation_method='Dynamic',
primary=True
)
]
Expand Down Expand Up @@ -875,7 +819,7 @@ def exec_module(self, **kwargs):
def get_or_create_public_ip_address(self, ip_config):
name = ip_config.get('public_ip_address_name')

if not (self.public_ip and name):
if not name:
return None

pip = self.get_public_ip_address(name)
Expand Down
5 changes: 4 additions & 1 deletion tests/integration/targets/azure_rm_image/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@
azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
name: "{{ vm_name }}"
ip_configurations:
- name: default
public_ip_address_name: "{{ public_ip_name }}"
primary: true
virtual_network: "{{ vm_name }}"
subnet: "{{ vm_name }}"
public_ip_name: "{{ public_ip_name }}"
security_group: "{{ security_group_name }}"

- name: Create virtual machine
Expand Down
Loading

0 comments on commit 9509489

Please sign in to comment.