From e1ae6fe42bc6f5a0a43361445c36ec272a9e1e2c Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 18:17:43 +0000 Subject: [PATCH] Add support to enable multicast on transit gateway (#2063) (#2119) This is a backport of PR #2063 as merged into main (4752c05). SUMMARY Need to enable multicast while creating transit gateway ISSUE TYPE Feature Pull Request COMPONENT NAME transit_gateway ADDITIONAL INFORMATION Reviewed-by: Alina Buzachis --- .../fragments/2063-add-multicast-support.yml | 2 ++ plugins/module_utils/transitgateway.py | 3 ++ plugins/modules/ec2_transit_gateway.py | 14 ++++++++ plugins/modules/ec2_transit_gateway_info.py | 7 ++++ .../ec2_transit_gateway/tasks/main.yml | 34 +++++++++++++++++-- 5 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/2063-add-multicast-support.yml diff --git a/changelogs/fragments/2063-add-multicast-support.yml b/changelogs/fragments/2063-add-multicast-support.yml new file mode 100644 index 00000000000..ed6ec1e9eb3 --- /dev/null +++ b/changelogs/fragments/2063-add-multicast-support.yml @@ -0,0 +1,2 @@ +minor_changes: + - ec2_transit_gateway - Support for enable multicast on Transit Gateway (https://github.com/ansible-collections/community.aws/pull/2063). diff --git a/plugins/module_utils/transitgateway.py b/plugins/module_utils/transitgateway.py index 5f0e934d1f2..8a82a839ff1 100644 --- a/plugins/module_utils/transitgateway.py +++ b/plugins/module_utils/transitgateway.py @@ -192,6 +192,9 @@ def _set_option(self, name, value): def set_dns_support(self, value): return self._set_option("DnsSupport", value) + def set_multicast_support(self, value): + return self._set_option("MulticastSupport", value) + def set_ipv6_support(self, value): return self._set_option("Ipv6Support", value) diff --git a/plugins/modules/ec2_transit_gateway.py b/plugins/modules/ec2_transit_gateway.py index 19876984dba..c3a1079e5c9 100644 --- a/plugins/modules/ec2_transit_gateway.py +++ b/plugins/modules/ec2_transit_gateway.py @@ -42,6 +42,11 @@ - Whether to enable AWS DNS support. default: true type: bool + multicast_support: + description: + - Whether to enable AWS Multicast support. Valid only at the time of creation of the Transit Gateway. + type: bool + version_added: 8.1.0 state: description: - C(present) to ensure resource is created. @@ -91,6 +96,7 @@ asn: 64514 auto_associate: false auto_propagate: false + multicast_support: true dns_support: true description: "nonprod transit gateway" purge_tags: false @@ -181,6 +187,12 @@ returned: always type: str sample: enable + multicast_support: + description: Indicates whether Multicast support is enabled. + returned: always + type: str + sample: enable + version_added: 7.3.0 owner_id: description: The account that owns the transit gateway. returned: always @@ -362,6 +374,7 @@ def create_tgw(self, description): options["DefaultRouteTablePropagation"] = self.enable_option_flag(self._module.params.get("auto_propagate")) options["VpnEcmpSupport"] = self.enable_option_flag(self._module.params.get("vpn_ecmp_support")) options["DnsSupport"] = self.enable_option_flag(self._module.params.get("dns_support")) + options["MulticastSupport"] = self.enable_option_flag(self._module.params.get("multicast_support")) try: response = self._connection.create_transit_gateway(Description=description, Options=options) @@ -482,6 +495,7 @@ def setup_module_object(): auto_attach=dict(type="bool", default=False), auto_propagate=dict(type="bool", default=True), description=dict(type="str"), + multicast_support=dict(type="bool"), dns_support=dict(type="bool", default=True), purge_tags=dict(type="bool", default=True), state=dict(default="present", choices=["present", "absent"]), diff --git a/plugins/modules/ec2_transit_gateway_info.py b/plugins/modules/ec2_transit_gateway_info.py index b25346b84b8..014c875b6a0 100644 --- a/plugins/modules/ec2_transit_gateway_info.py +++ b/plugins/modules/ec2_transit_gateway_info.py @@ -119,6 +119,13 @@ returned: always type: str sample: "enable" + multicast_support: + description: + - Indicates whether Multicast support is enabled. + returned: always + type: str + sample: "enable" + version_added: 7.3.0 propagation_default_route_table_id: description: - The ID of the default propagation route table. diff --git a/tests/integration/targets/ec2_transit_gateway/tasks/main.yml b/tests/integration/targets/ec2_transit_gateway/tasks/main.yml index c7353cfc0a6..241c9c2c324 100644 --- a/tests/integration/targets/ec2_transit_gateway/tasks/main.yml +++ b/tests/integration/targets/ec2_transit_gateway/tasks/main.yml @@ -22,7 +22,7 @@ assert: that: - create_result.changed == True - + - name: test update transit gateway with tags by description ec2_transit_gateway: description: "{{ tgw_description }}" @@ -75,6 +75,32 @@ assert: that: - result.changed == False + + - name: generate unique value for testing + set_fact: + tgw_description_multicast: "{{ resource_prefix }}-tgw-multicast" + + - name: test create transit gateway with multicast enabled + ec2_transit_gateway: + description: "{{ tgw_description_multicast }}" + multicast_support: true + register: create_result + + - name: assert changed is True + assert: + that: + - create_result.changed == True + + - name: test success with filter + ec2_transit_gateway_info: + filters: + options.multicast-support: enable + register: result + + - name: assert success with multicast-support filter + assert: + that: + - 'result.transit_gateways != []' # ==== Combine ec2_transit_gateway_info ====================== - name: test success with no parameters @@ -129,10 +155,14 @@ that: - 'result.changed == false' - 'result.transit_gateways != []' + always: ###### TEARDOWN STARTS HERE ###### - name: delete transit gateway ec2_transit_gateway: - description: "{{ tgw_description }}" + description: "{{ item }}" state: absent ignore_errors: yes + loop: + - "{{ tgw_description }}" + - "{{ tgw_description_multicast }}"