From 7dd005d5f523bd4c64b90cd02f95033fc6dcc0cb Mon Sep 17 00:00:00 2001 From: Alina Buzachis Date: Wed, 16 Oct 2024 13:45:41 +0200 Subject: [PATCH] Remove collection reference inside the tests --- .../targets/ec2_vpc_peer/defaults/main.yml | 5 +- .../targets/ec2_vpc_peer/tasks/main.yml | 494 +++++++++--------- 2 files changed, 250 insertions(+), 249 deletions(-) diff --git a/tests/integration/targets/ec2_vpc_peer/defaults/main.yml b/tests/integration/targets/ec2_vpc_peer/defaults/main.yml index 0ff34455b45..99698043b5e 100644 --- a/tests/integration/targets/ec2_vpc_peer/defaults/main.yml +++ b/tests/integration/targets/ec2_vpc_peer/defaults/main.yml @@ -1,6 +1,5 @@ ---- vpc_seed: '{{ resource_prefix }}' vpc_1_name: '{{ resource_prefix }}-vpc-1' -vpc_1_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.0.0/23' +vpc_1_cidr: 10.{{ 256 | random(seed=vpc_seed) }}.0.0/23 vpc_2_name: '{{ resource_prefix }}-vpc-1' -vpc_2_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.2.0/23' +vpc_2_cidr: 10.{{ 256 | random(seed=vpc_seed) }}.2.0/23 diff --git a/tests/integration/targets/ec2_vpc_peer/tasks/main.yml b/tests/integration/targets/ec2_vpc_peer/tasks/main.yml index 859e482b319..864b5143975 100644 --- a/tests/integration/targets/ec2_vpc_peer/tasks/main.yml +++ b/tests/integration/targets/ec2_vpc_peer/tasks/main.yml @@ -1,13 +1,10 @@ ---- - name: EC2 VPC Peering Connection integration tests - collections: - - amazon.aws module_defaults: group/aws: - access_key: "{{ aws_access_key }}" - secret_key: "{{ aws_secret_key }}" - session_token: "{{ security_token | default(omit) }}" - region: "{{ aws_region }}" + access_key: '{{ aws_access_key }}' + secret_key: '{{ aws_secret_key }}' + session_token: '{{ security_token | default(omit) }}' + region: '{{ aws_region }}' block: - name: Get ARN of calling user aws_caller_info: @@ -21,44 +18,44 @@ - name: Fetch EC2 VPC Peering Connections in check_mode community.aws.ec2_vpc_peering_info: register: peers_info - check_mode: True + check_mode: true - name: Assert success ansible.builtin.assert: that: - - peers_info is successful - - '"result" in peers_info' + - peers_info is successful + - '"result" in peers_info' # ============================================================ - name: Create VPC 1 amazon.aws.ec2_vpc_net: - name: "{{ vpc_1_name }}" + name: '{{ vpc_1_name }}' state: present - cidr_block: "{{ vpc_1_cidr }}" + cidr_block: '{{ vpc_1_cidr }}' tags: - Name: "{{ vpc_1_name }}" - TestPrefex: "{{ resource_prefix }}" + Name: '{{ vpc_1_name }}' + TestPrefex: '{{ resource_prefix }}' register: vpc_1_result - name: Assert success ansible.builtin.assert: that: - - vpc_1_result is successful + - vpc_1_result is successful - name: Create VPC 2 amazon.aws.ec2_vpc_net: - name: "{{ vpc_2_name }}" + name: '{{ vpc_2_name }}' state: present - cidr_block: "{{ vpc_2_cidr }}" + cidr_block: '{{ vpc_2_cidr }}' tags: - Name: "{{ vpc_2_name }}" - TestPrefex: "{{ resource_prefix }}" + Name: '{{ vpc_2_name }}' + TestPrefex: '{{ resource_prefix }}' register: vpc_2_result - name: Assert success ansible.builtin.assert: that: - - vpc_2_result is successful + - vpc_2_result is successful - name: Store VPC IDs set_fact: @@ -67,7 +64,7 @@ - name: Set a name to use with the connections ansible.builtin.set_fact: - connection_name: 'Peering connection for VPC {{ vpc_1 }} to VPC {{ vpc_2 }}' + connection_name: Peering connection for VPC {{ vpc_1 }} to VPC {{ vpc_2 }} - name: Create local account EC2 VPC Peering Connection request (check_mode) community.aws.ec2_vpc_peer: @@ -82,7 +79,7 @@ - name: Assert success ansible.builtin.assert: that: - - vpc_peer is changed + - vpc_peer is changed - name: Create local account EC2 VPC Peering Connection request community.aws.ec2_vpc_peer: @@ -96,17 +93,18 @@ - name: Assert success ansible.builtin.assert: that: - - vpc_peer is changed - - vpc_peer is successful - - "'peering_id' in vpc_peer" - - vpc_peer.vpc_peering_connection.requester_vpc_info.cidr_block == vpc_1_cidr - - vpc_peer.peering_id.startswith('pcx-') + - vpc_peer is changed + - vpc_peer is successful + - "'peering_id' in vpc_peer" + - vpc_peer.vpc_peering_connection.requester_vpc_info.cidr_block == vpc_1_cidr + - vpc_peer.peering_id.startswith('pcx-') - name: Store Connection ID ansible.builtin.set_fact: peer_id_1: '{{ vpc_peer.peering_id }}' - - name: Re-create local account EC2 VPC Peering Connection request (idempotency check_mode) + - name: Re-create local account EC2 VPC Peering Connection request (idempotency + check_mode) community.aws.ec2_vpc_peer: vpc_id: '{{ vpc_1 }}' peer_vpc_id: '{{ vpc_2 }}' @@ -119,7 +117,7 @@ - name: Assert success ansible.builtin.assert: that: - - vpc_peer is not changed + - vpc_peer is not changed - name: Re-create local account EC2 VPC Peering Connection request (idempotency) community.aws.ec2_vpc_peer: @@ -133,11 +131,12 @@ - name: Assert success ansible.builtin.assert: that: - - vpc_peer is not changed - - vpc_peer is successful - - vpc_peer.peering_id == peer_id_1 + - vpc_peer is not changed + - vpc_peer is successful + - vpc_peer.peering_id == peer_id_1 - - name: Create local account EC2 VPC Peering Connection request with accepter/requester reversed (idempotency check_mode) + - name: Create local account EC2 VPC Peering Connection request with accepter/requester + reversed (idempotency check_mode) community.aws.ec2_vpc_peer: vpc_id: '{{ vpc_2 }}' peer_vpc_id: '{{ vpc_1 }}' @@ -150,9 +149,10 @@ - name: Assert success ansible.builtin.assert: that: - - vpc_peer is not changed + - vpc_peer is not changed - - name: Create local account EC2 VPC Peering Connection request with accepter/requester reversed (idempotency) + - name: Create local account EC2 VPC Peering Connection request with accepter/requester + reversed (idempotency) community.aws.ec2_vpc_peer: vpc_id: '{{ vpc_2 }}' peer_vpc_id: '{{ vpc_1 }}' @@ -164,57 +164,57 @@ - name: Assert success ansible.builtin.assert: that: - - vpc_peer is not changed - - vpc_peer is successful - - vpc_peer.peering_id == peer_id_1 + - vpc_peer is not changed + - vpc_peer is successful + - vpc_peer.peering_id == peer_id_1 - name: Get details on specific EC2 VPC Peering Connection community.aws.ec2_vpc_peering_info: peer_connection_ids: - - '{{ peer_id_1 }}' + - '{{ peer_id_1 }}' register: peer_info - name: Assert expected values ansible.builtin.assert: that: - - peer_info is successful - - "'vpc_peering_connections' in peer_info" - - "'result' in peer_info" - - "'accepter_vpc_info' in peer_details" - - "'requester_vpc_info' in peer_details" - - "'status' in peer_details" - - "'code' in peer_details.status" - - peer_details.status.code == "pending-acceptance" - - "'message' in peer_details.status" - - "'tags' in peer_details" - - "'Name' in peer_details.tags" - - peer_details.tags.Name == connection_name - - "'vpc_peering_connection_id' in peer_details" - - peer_details.vpc_peering_connection_id == peer_id_1 + - peer_info is successful + - "'vpc_peering_connections' in peer_info" + - "'result' in peer_info" + - "'accepter_vpc_info' in peer_details" + - "'requester_vpc_info' in peer_details" + - "'status' in peer_details" + - "'code' in peer_details.status" + - peer_details.status.code == "pending-acceptance" + - "'message' in peer_details.status" + - "'tags' in peer_details" + - "'Name' in peer_details.tags" + - peer_details.tags.Name == connection_name + - "'vpc_peering_connection_id' in peer_details" + - peer_details.vpc_peering_connection_id == peer_id_1 # Acceptor info isn't available until the connection has been accepted - - "'cidr_block' not in acceptor_details" - - "'cidr_block_set' not in acceptor_details" - - "'peering_options' not in acceptor_details" - - "'owner_id' in acceptor_details" - - acceptor_details.owner_id == account_id - - "'region' in acceptor_details" - - acceptor_details.region == aws_region - - "'vpc_id' in acceptor_details" - - acceptor_details.vpc_id == vpc_2 + - "'cidr_block' not in acceptor_details" + - "'cidr_block_set' not in acceptor_details" + - "'peering_options' not in acceptor_details" + - "'owner_id' in acceptor_details" + - acceptor_details.owner_id == account_id + - "'region' in acceptor_details" + - acceptor_details.region == aws_region + - "'vpc_id' in acceptor_details" + - acceptor_details.vpc_id == vpc_2 # Information about the 'requesting' VPC - - "'cidr_block' in requester_details" - - requester_details.cidr_block == vpc_1_cidr - - "'cidr_block_set' in requester_details" - - requester_details.cidr_block_set | length == 1 - - "'cidr_block' in requester_details.cidr_block_set[0]" - - requester_details.cidr_block_set[0].cidr_block == vpc_1_cidr - - "'peering_options' in requester_details" - - "'owner_id' in requester_details" - - requester_details.owner_id == account_id - - "'region' in requester_details" - - requester_details.region == aws_region - - "'vpc_id' in requester_details" - - requester_details.vpc_id == vpc_1 + - "'cidr_block' in requester_details" + - requester_details.cidr_block == vpc_1_cidr + - "'cidr_block_set' in requester_details" + - requester_details.cidr_block_set | length == 1 + - "'cidr_block' in requester_details.cidr_block_set[0]" + - requester_details.cidr_block_set[0].cidr_block == vpc_1_cidr + - "'peering_options' in requester_details" + - "'owner_id' in requester_details" + - requester_details.owner_id == account_id + - "'region' in requester_details" + - requester_details.region == aws_region + - "'vpc_id' in requester_details" + - requester_details.vpc_id == vpc_1 vars: peer_details: '{{ peer_info.vpc_peering_connections[0] }}' acceptor_details: '{{ peer_details["accepter_vpc_info"] }}' @@ -223,39 +223,39 @@ - name: Get all EC2 VPC Peering Connections with specific filters community.aws.ec2_vpc_peering_info: filters: - status-code: ['pending-acceptance'] + status-code: [pending-acceptance] register: pending_vpc_peers - name: Assert expected values ansible.builtin.assert: that: # Not guaranteed to just be us, only assert the shape - - pending_vpc_peers is successful - - "'vpc_peering_connections' in peer_info" - - "'result' in peer_info" - - "'accepter_vpc_info' in peer_details" - - "'requester_vpc_info' in peer_details" - - "'status' in peer_details" - - "'code' in peer_details.status" - - peer_details.status.code == "pending-acceptance" - - "'message' in peer_details.status" - - "'tags' in peer_details" - - "'vpc_peering_connection_id' in peer_details" + - pending_vpc_peers is successful + - "'vpc_peering_connections' in peer_info" + - "'result' in peer_info" + - "'accepter_vpc_info' in peer_details" + - "'requester_vpc_info' in peer_details" + - "'status' in peer_details" + - "'code' in peer_details.status" + - peer_details.status.code == "pending-acceptance" + - "'message' in peer_details.status" + - "'tags' in peer_details" + - "'vpc_peering_connection_id' in peer_details" # Acceptor info isn't available until the connection has been accepted - - "'cidr_block' not in acceptor_details" - - "'cidr_block_set' not in acceptor_details" - - "'peering_options' not in acceptor_details" - - "'owner_id' in acceptor_details" - - "'region' in acceptor_details" - - "'vpc_id' in acceptor_details" + - "'cidr_block' not in acceptor_details" + - "'cidr_block_set' not in acceptor_details" + - "'peering_options' not in acceptor_details" + - "'owner_id' in acceptor_details" + - "'region' in acceptor_details" + - "'vpc_id' in acceptor_details" # Information about the 'requesting' VPC - - "'cidr_block' in requester_details" - - "'cidr_block_set' in requester_details" - - "'cidr_block' in requester_details.cidr_block_set[0]" - - "'peering_options' in requester_details" - - "'owner_id' in requester_details" - - "'region' in requester_details" - - "'vpc_id' in requester_details" + - "'cidr_block' in requester_details" + - "'cidr_block_set' in requester_details" + - "'cidr_block' in requester_details.cidr_block_set[0]" + - "'peering_options' in requester_details" + - "'owner_id' in requester_details" + - "'region' in requester_details" + - "'vpc_id' in requester_details" vars: peer_details: '{{ pending_vpc_peers.vpc_peering_connections[0] }}' acceptor_details: '{{ peer_details["accepter_vpc_info"] }}' @@ -275,7 +275,7 @@ - name: Assert success ansible.builtin.assert: that: - - tag_peer is changed + - tag_peer is changed - name: Update tags on the EC2 VPC Peering Connection community.aws.ec2_vpc_peer: @@ -290,9 +290,9 @@ - name: Assert success ansible.builtin.assert: that: - - tag_peer is changed - - tag_peer is successful - - tag_peer.peering_id == peer_id_1 + - tag_peer is changed + - tag_peer is successful + - tag_peer.peering_id == peer_id_1 - name: Update tags on the EC2 VPC Peering Connection (idempotency check_mode) community.aws.ec2_vpc_peer: @@ -308,7 +308,7 @@ - name: Assert success ansible.builtin.assert: that: - - tag_peer is not changed + - tag_peer is not changed - name: Update tags on the EC2 VPC Peering Connection (idempotency) community.aws.ec2_vpc_peer: @@ -323,31 +323,31 @@ - name: Assert success ansible.builtin.assert: that: - - tag_peer is not changed - - tag_peer is successful - - tag_peer.peering_id == peer_id_1 + - tag_peer is not changed + - tag_peer is successful + - tag_peer.peering_id == peer_id_1 - name: Get details on specific EC2 VPC Peering Connection community.aws.ec2_vpc_peering_info: peer_connection_ids: - - '{{ peer_id_1 }}' + - '{{ peer_id_1 }}' register: peer_info - name: Assert expected tags ansible.builtin.assert: that: - - peer_info is successful - - "'tags' in peer_details" - - "'Name' in peer_details.tags" - - "'testPrefix' in peer_details.tags" - - peer_details.tags.Name == connection_name - - peer_details.tags.testPrefix == resource_prefix + - peer_info is successful + - "'tags' in peer_details" + - "'Name' in peer_details.tags" + - "'testPrefix' in peer_details.tags" + - peer_details.tags.Name == connection_name + - peer_details.tags.testPrefix == resource_prefix vars: peer_details: '{{ peer_info.vpc_peering_connections[0] }}' - name: Accept local EC2 VPC Peering request (check_mode) community.aws.ec2_vpc_peer: - peering_id: "{{ vpc_peer.peering_id }}" + peering_id: '{{ vpc_peer.peering_id }}' state: accept wait: true check_mode: true @@ -356,11 +356,11 @@ - name: Assert success ansible.builtin.assert: that: - - action_peer is changed + - action_peer is changed - name: Accept local EC2 VPC Peering request community.aws.ec2_vpc_peer: - peering_id: "{{ vpc_peer.peering_id }}" + peering_id: '{{ vpc_peer.peering_id }}' state: accept wait: true register: action_peer @@ -368,65 +368,65 @@ - name: Assert success ansible.builtin.assert: that: - - action_peer is changed - - action_peer is successful - - action_peer.peering_id == peer_id_1 - - action_peer.vpc_peering_connection.accepter_vpc_info.cidr_block == vpc_2_cidr - - action_peer.vpc_peering_connection.vpc_peering_connection_id == peer_id_1 + - action_peer is changed + - action_peer is successful + - action_peer.peering_id == peer_id_1 + - action_peer.vpc_peering_connection.accepter_vpc_info.cidr_block == vpc_2_cidr + - action_peer.vpc_peering_connection.vpc_peering_connection_id == peer_id_1 - name: Get details on specific EC2 VPC Peering Connection community.aws.ec2_vpc_peering_info: peer_connection_ids: - - '{{ peer_id_1 }}' + - '{{ peer_id_1 }}' register: peer_info - name: Assert expected values ansible.builtin.assert: that: - - peer_info is successful - - "'vpc_peering_connections' in peer_info" - - "'result' in peer_info" - - "'accepter_vpc_info' in peer_details" - - "'requester_vpc_info' in peer_details" - - "'status' in peer_details" - - "'code' in peer_details.status" - - peer_details.status.code == "active" - - "'message' in peer_details.status" - - "'tags' in peer_details" - - "'Name' in peer_details.tags" - - peer_details.tags.Name == connection_name - - "'testPrefix' in peer_details.tags" - - peer_details.tags.testPrefix == resource_prefix - - "'vpc_peering_connection_id' in peer_details" - - peer_details.vpc_peering_connection_id == peer_id_1 + - peer_info is successful + - "'vpc_peering_connections' in peer_info" + - "'result' in peer_info" + - "'accepter_vpc_info' in peer_details" + - "'requester_vpc_info' in peer_details" + - "'status' in peer_details" + - "'code' in peer_details.status" + - peer_details.status.code == "active" + - "'message' in peer_details.status" + - "'tags' in peer_details" + - "'Name' in peer_details.tags" + - peer_details.tags.Name == connection_name + - "'testPrefix' in peer_details.tags" + - peer_details.tags.testPrefix == resource_prefix + - "'vpc_peering_connection_id' in peer_details" + - peer_details.vpc_peering_connection_id == peer_id_1 # Information about the 'accepting' VPC should be available now - - "'cidr_block' in acceptor_details" - - acceptor_details.cidr_block == vpc_2_cidr - - "'cidr_block_set' in acceptor_details" - - acceptor_details.cidr_block_set | length == 1 - - "'cidr_block' in acceptor_details.cidr_block_set[0]" - - acceptor_details.cidr_block_set[0].cidr_block == vpc_2_cidr - - "'peering_options' in acceptor_details" - - "'owner_id' in acceptor_details" - - acceptor_details.owner_id == account_id - - "'region' in acceptor_details" - - acceptor_details.region == aws_region - - "'vpc_id' in acceptor_details" - - acceptor_details.vpc_id == vpc_2 + - "'cidr_block' in acceptor_details" + - acceptor_details.cidr_block == vpc_2_cidr + - "'cidr_block_set' in acceptor_details" + - acceptor_details.cidr_block_set | length == 1 + - "'cidr_block' in acceptor_details.cidr_block_set[0]" + - acceptor_details.cidr_block_set[0].cidr_block == vpc_2_cidr + - "'peering_options' in acceptor_details" + - "'owner_id' in acceptor_details" + - acceptor_details.owner_id == account_id + - "'region' in acceptor_details" + - acceptor_details.region == aws_region + - "'vpc_id' in acceptor_details" + - acceptor_details.vpc_id == vpc_2 # Information about the 'requesting' VPC - - "'cidr_block' in requester_details" - - requester_details.cidr_block == vpc_1_cidr - - "'cidr_block_set' in requester_details" - - requester_details.cidr_block_set | length == 1 - - "'cidr_block' in requester_details.cidr_block_set[0]" - - requester_details.cidr_block_set[0].cidr_block == vpc_1_cidr - - "'peering_options' in requester_details" - - "'owner_id' in requester_details" - - requester_details.owner_id == account_id - - "'region' in requester_details" - - requester_details.region == aws_region - - "'vpc_id' in requester_details" - - requester_details.vpc_id == vpc_1 + - "'cidr_block' in requester_details" + - requester_details.cidr_block == vpc_1_cidr + - "'cidr_block_set' in requester_details" + - requester_details.cidr_block_set | length == 1 + - "'cidr_block' in requester_details.cidr_block_set[0]" + - requester_details.cidr_block_set[0].cidr_block == vpc_1_cidr + - "'peering_options' in requester_details" + - "'owner_id' in requester_details" + - requester_details.owner_id == account_id + - "'region' in requester_details" + - requester_details.region == aws_region + - "'vpc_id' in requester_details" + - requester_details.vpc_id == vpc_1 vars: peer_details: '{{ peer_info.vpc_peering_connections[0] }}' acceptor_details: '{{ peer_details["accepter_vpc_info"] }}' @@ -434,7 +434,7 @@ - name: Accept local EC2 VPC Peering request (idempotency check_mode) community.aws.ec2_vpc_peer: - peering_id: "{{ vpc_peer.peering_id }}" + peering_id: '{{ vpc_peer.peering_id }}' state: accept check_mode: true register: action_peer @@ -442,25 +442,25 @@ - name: Assert success ansible.builtin.assert: that: - - action_peer is not changed + - action_peer is not changed - name: Accept local EC2 VPC Peering request (idempotency) community.aws.ec2_vpc_peer: - peering_id: "{{ vpc_peer.peering_id }}" + peering_id: '{{ vpc_peer.peering_id }}' state: accept register: action_peer - name: Assert success ansible.builtin.assert: that: - - action_peer is not changed - - action_peer is successful - - action_peer.peering_id == peer_id_1 - - action_peer.vpc_peering_connection.vpc_peering_connection_id == peer_id_1 + - action_peer is not changed + - action_peer is successful + - action_peer.peering_id == peer_id_1 + - action_peer.vpc_peering_connection.vpc_peering_connection_id == peer_id_1 - name: Delete a local EC2 VPC Peering Connection (check_mode) community.aws.ec2_vpc_peer: - peering_id: "{{ vpc_peer.peering_id }}" + peering_id: '{{ vpc_peer.peering_id }}' state: absent check_mode: true register: delete_peer @@ -468,66 +468,66 @@ - name: Assert success ansible.builtin.assert: that: - - delete_peer is changed + - delete_peer is changed - name: Delete a local EC2 VPC Peering Connection community.aws.ec2_vpc_peer: - peering_id: "{{ vpc_peer.peering_id }}" + peering_id: '{{ vpc_peer.peering_id }}' state: absent register: delete_peer - name: Assert success ansible.builtin.assert: that: - - delete_peer is changed - - delete_peer is successful - - "'peering_id' in delete_peer" + - delete_peer is changed + - delete_peer is successful + - "'peering_id' in delete_peer" - name: Get details on specific EC2 VPC Peering Connection community.aws.ec2_vpc_peering_info: peer_connection_ids: - - '{{ peer_id_1}}' + - '{{ peer_id_1}}' register: peer_info - name: Assert expected values ansible.builtin.assert: that: - - peer_info is successful - - "'vpc_peering_connections' in peer_info" - - "'result' in peer_info" - - "'accepter_vpc_info' in peer_details" - - "'requester_vpc_info' in peer_details" - - "'status' in peer_details" - - "'code' in peer_details.status" - - peer_details.status.code == "deleted" - - "'message' in peer_details.status" - - "'tags' in peer_details" - - "'Name' in peer_details.tags" - - peer_details.tags.Name == connection_name - - "'testPrefix' in peer_details.tags" - - peer_details.tags.testPrefix == resource_prefix - - "'vpc_peering_connection_id' in peer_details" - - peer_details.vpc_peering_connection_id == peer_id_1 + - peer_info is successful + - "'vpc_peering_connections' in peer_info" + - "'result' in peer_info" + - "'accepter_vpc_info' in peer_details" + - "'requester_vpc_info' in peer_details" + - "'status' in peer_details" + - "'code' in peer_details.status" + - peer_details.status.code == "deleted" + - "'message' in peer_details.status" + - "'tags' in peer_details" + - "'Name' in peer_details.tags" + - peer_details.tags.Name == connection_name + - "'testPrefix' in peer_details.tags" + - peer_details.tags.testPrefix == resource_prefix + - "'vpc_peering_connection_id' in peer_details" + - peer_details.vpc_peering_connection_id == peer_id_1 # Information about the 'accepting' VPC is reduced again - - "'cidr_block' not in acceptor_details" - - "'cidr_block_set' not in acceptor_details" - - "'peering_options' not in acceptor_details" - - "'owner_id' in acceptor_details" - - acceptor_details.owner_id == account_id - - "'region' in acceptor_details" - - acceptor_details.region == aws_region - - "'vpc_id' in acceptor_details" - - acceptor_details.vpc_id == vpc_2 + - "'cidr_block' not in acceptor_details" + - "'cidr_block_set' not in acceptor_details" + - "'peering_options' not in acceptor_details" + - "'owner_id' in acceptor_details" + - acceptor_details.owner_id == account_id + - "'region' in acceptor_details" + - acceptor_details.region == aws_region + - "'vpc_id' in acceptor_details" + - acceptor_details.vpc_id == vpc_2 # Information about the 'requesting' VPC is reduced once the VPC's deleted - - "'cidr_block' not in requester_details" - - "'cidr_block_set' not in requester_details" - - "'peering_options' not in requester_details" - - "'owner_id' in requester_details" - - requester_details.owner_id == account_id - - "'region' in requester_details" - - requester_details.region == aws_region - - "'vpc_id' in requester_details" - - requester_details.vpc_id == vpc_1 + - "'cidr_block' not in requester_details" + - "'cidr_block_set' not in requester_details" + - "'peering_options' not in requester_details" + - "'owner_id' in requester_details" + - requester_details.owner_id == account_id + - "'region' in requester_details" + - requester_details.region == aws_region + - "'vpc_id' in requester_details" + - requester_details.vpc_id == vpc_1 vars: peer_details: '{{ peer_info.vpc_peering_connections[0] }}' acceptor_details: '{{ peer_details["accepter_vpc_info"] }}' @@ -535,7 +535,7 @@ - name: Delete a local EC2 VPC Peering Connection (idempotency check_mode) community.aws.ec2_vpc_peer: - peering_id: "{{ vpc_peer.peering_id }}" + peering_id: '{{ vpc_peer.peering_id }}' state: absent check_mode: true register: delete_peer @@ -543,19 +543,19 @@ - name: Assert success ansible.builtin.assert: that: - - delete_peer is not changed + - delete_peer is not changed - name: Delete a local EC2 VPC Peering Connection (idempotency) community.aws.ec2_vpc_peer: - peering_id: "{{ vpc_peer.peering_id }}" + peering_id: '{{ vpc_peer.peering_id }}' state: absent register: delete_peer - name: Assert success ansible.builtin.assert: that: - - delete_peer is not changed - - delete_peer is successful + - delete_peer is not changed + - delete_peer is successful - name: Create local account EC2 VPC Peering Connection community.aws.ec2_vpc_peer: @@ -563,16 +563,16 @@ peer_vpc_id: '{{ vpc_2 }}' state: present tags: - Name: 'Peering connection for VPC {{ vpc_1 }} to VPC {{ vpc_2 }}' + Name: Peering connection for VPC {{ vpc_1 }} to VPC {{ vpc_2 }} register: vpc_peer2 - name: Assert success ansible.builtin.assert: that: - - vpc_peer2 is changed - - vpc_peer2 is successful - - "'peering_id' in vpc_peer2" - - vpc_peer2.peering_id.startswith('pcx-') + - vpc_peer2 is changed + - vpc_peer2 is successful + - "'peering_id' in vpc_peer2" + - vpc_peer2.peering_id.startswith('pcx-') - name: Store Connection ID ansible.builtin.set_fact: @@ -580,43 +580,43 @@ - name: Reject a local EC2 VPC Peering Connection community.aws.ec2_vpc_peer: - peering_id: "{{ vpc_peer2.peering_id }}" + peering_id: '{{ vpc_peer2.peering_id }}' state: reject - wait: True + wait: true register: reject_peer - name: Assert success ansible.builtin.assert: that: - - reject_peer is changed - - reject_peer is successful - - reject_peer.peering_id == peer_id_2 + - reject_peer is changed + - reject_peer is successful + - reject_peer.peering_id == peer_id_2 - name: Reject a local EC2 VPC Peering Connection (idempotency) community.aws.ec2_vpc_peer: - peering_id: "{{ vpc_peer2.peering_id }}" + peering_id: '{{ vpc_peer2.peering_id }}' state: reject register: reject_peer - name: Assert success ansible.builtin.assert: that: - - reject_peer is not changed - - reject_peer is successful - - reject_peer.peering_id == peer_id_2 - - reject_peer.vpc_peering_connection.vpc_peering_connection_id == peer_id_2 + - reject_peer is not changed + - reject_peer is successful + - reject_peer.peering_id == peer_id_2 + - reject_peer.vpc_peering_connection.vpc_peering_connection_id == peer_id_2 - name: Delete a local EC2 VPC Peering Connections community.aws.ec2_vpc_peer: - peering_id: "{{ vpc_peer2.peering_id }}" + peering_id: '{{ vpc_peer2.peering_id }}' state: absent register: delete_peer - name: Assert success ansible.builtin.assert: that: - - delete_peer is not changed - - delete_peer is successful + - delete_peer is not changed + - delete_peer is successful always: @@ -630,26 +630,28 @@ - '{{ vpc_2 }}' - ansible.builtin.set_fact: - vpc_peering_connection_ids: '{{ _vpc_peering_connections | map(attribute="vpc_peering_connection_id") | list }}' + vpc_peering_connection_ids: '{{ _vpc_peering_connections | map(attribute="vpc_peering_connection_id") + | list }}' vars: - _vpc_peering_connections: '{{ peering_info.results | map(attribute="vpc_peering_connections") | flatten }}' - ignore_errors: True + _vpc_peering_connections: '{{ peering_info.results | map(attribute="vpc_peering_connections") + | flatten }}' + ignore_errors: true # ============================================================ - name: Delete remaining EC2 VPC Peering Connections community.aws.ec2_vpc_peer: - peering_id: "{{ item }}" + peering_id: '{{ item }}' state: absent - ignore_errors: True + ignore_errors: true loop: '{{ vpc_peering_connection_ids }}' - name: Tidy up VPCs amazon.aws.ec2_vpc_net: - name: "{{ item.name }}" + name: '{{ item.name }}' state: absent - cidr_block: "{{ item.cidr }}" + cidr_block: '{{ item.cidr }}' ignore_errors: true loop: - - { name: "{{ vpc_2_name }}", cidr: "{{ vpc_2_cidr }}"} - - { name: "{{ vpc_1_name }}", cidr: "{{ vpc_1_cidr }}"} + - {name: '{{ vpc_2_name }}', cidr: '{{ vpc_2_cidr }}'} + - {name: '{{ vpc_1_name }}', cidr: '{{ vpc_1_cidr }}'}