From 4ac381518b7fd4cd826a46c968ba3b753575c519 Mon Sep 17 00:00:00 2001 From: Fred-sun Date: Mon, 2 Dec 2024 23:38:22 +0800 Subject: [PATCH 1/2] Add support 'enable_tcp_reset' to azure_rm_loadbalancecer --- plugins/modules/azure_rm_loadbalancer.py | 9 +++++++++ .../targets/azure_rm_loadbalancer/tasks/main.yml | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/plugins/modules/azure_rm_loadbalancer.py b/plugins/modules/azure_rm_loadbalancer.py index 5a62c1be4..da5359852 100644 --- a/plugins/modules/azure_rm_loadbalancer.py +++ b/plugins/modules/azure_rm_loadbalancer.py @@ -259,6 +259,11 @@ description: - Configures a virtual machine's endpoint for the floating IP capability required to configure a SQL AlwaysOn Availability Group. type: bool + enable_tcp_reset: + description: + - 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. + type: bool disable_outbound_snat: description: - Configure outbound source network address translation (SNAT). @@ -560,6 +565,9 @@ type='bool', default=False ), + enable_tcp_reset=dict( + type='bool' + ) ) @@ -745,6 +753,7 @@ def exec_module(self, **kwargs): backend_port=item.get('backend_port'), idle_timeout_in_minutes=item.get('idle_timeout'), enable_floating_ip=item.get('enable_floating_ip'), + enable_tcp_reset=item.get('enable_tcp_reset'), disable_outbound_snat=item.get('disable_outbound_snat'), ) for item in self.load_balancing_rules] if self.load_balancing_rules else None diff --git a/tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml b/tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml index 692590994..589a588c1 100644 --- a/tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml +++ b/tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml @@ -124,6 +124,7 @@ idle_timeout: 4 load_distribution: Default protocol: Tcp + enable_tcp_reset: true register: output - name: Assert complex load balancer created @@ -165,6 +166,7 @@ idle_timeout: 4 load_distribution: Default protocol: Tcp + enable_tcp_reset: true register: output - name: Assert that output has not changed @@ -205,6 +207,7 @@ idle_timeout: 4 load_distribution: Default protocol: Tcp + enable_tcp_reset: false register: output - name: Assert that output has changed @@ -212,6 +215,17 @@ that: - output.changed +- name: Get the load balancer facts + azure_rm_loadbalancer_info: + resource_group: '{{ resource_group }}' + name: "{{ lbname_b }}" + register: output + +- name: Assert the load balancer facts + ansible.builtin.assert: + - output.loadbalancers[0].load_balancing_rules[0].enable_tcp_reset is false + - output.loadbalancers[0].load_balancing_rules[0].frontend_port == 81 + - name: Delete load balancer azure_rm_loadbalancer: resource_group: '{{ resource_group }}' From 60dd288b510b3005672318b7cb930bd603494e35 Mon Sep 17 00:00:00 2001 From: Fred-sun Date: Mon, 2 Dec 2024 23:46:40 +0800 Subject: [PATCH 2/2] small change --- .../integration/targets/azure_rm_loadbalancer/tasks/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml b/tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml index 589a588c1..deac02db0 100644 --- a/tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml +++ b/tests/integration/targets/azure_rm_loadbalancer/tasks/main.yml @@ -223,8 +223,9 @@ - name: Assert the load balancer facts ansible.builtin.assert: - - output.loadbalancers[0].load_balancing_rules[0].enable_tcp_reset is false - - output.loadbalancers[0].load_balancing_rules[0].frontend_port == 81 + that: + - output.loadbalancers[0].load_balancing_rules[0].enable_tcp_reset is false + - output.loadbalancers[0].load_balancing_rules[0].frontend_port == 81 - name: Delete load balancer azure_rm_loadbalancer: