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

ec2_vpc_net: handle ipv6_cidr: false and no Ipv6CidrBlockAssociationSet in vpc #2374

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions changelogs/fragments/handle_vpc_ipv6_false.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- ec2_vpc_net - handle ipv6_cidr ``false`` and no Ipv6CidrBlockAssociationSet in vpc (https://github.com/ansible-collections/amazon.aws/pull/2374).
3 changes: 3 additions & 0 deletions plugins/modules/ec2_vpc_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ def wait_for_vpc_ipv6_state(module, connection, vpc_id, ipv6_assoc_state):
current_value = get_vpc(module, connection, vpc_id)
if current_value:
ipv6_set = current_value.get("Ipv6CidrBlockAssociationSet")
# "ipv6_cidr": false and no Ipv6CidrBlockAssociationSet
if not ipv6_set and not ipv6_assoc_state:
return
if ipv6_set:
if ipv6_assoc_state:
# At least one 'Amazon' IPv6 CIDR block must be associated.
Expand Down
21 changes: 18 additions & 3 deletions tests/integration/targets/ec2_vpc_net/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1491,9 +1491,24 @@
- result is changed
- result.vpc.ipv6_cidr_block_association_set | length == 1
- result.vpc.ipv6_cidr_block_association_set[0].association_id.startswith("vpc-cidr-assoc-")
- result.vpc.ipv6_cidr_block_association_set[0].ipv6_cidr_block | ansible.netcommon.ipv6
- result.vpc.ipv6_cidr_block_association_set[0].ipv6_cidr_block | ansible.utils.ipv6
- result.vpc.ipv6_cidr_block_association_set[0].ipv6_cidr_block_state.state in ["disassociated"]


- name: Retry to remove IPv6 CIDR association from VPC
amazon.aws.ec2_vpc_net:
state: present
cidr_block: "{{ vpc_cidr }}"
name: "{{ vpc_name }}"
ipv6_cidr: false
register: result

- name: assert the task passes and there is no change
ansible.builtin.assert:
that:
- result is successful
- result is not changed

- name: Add IPv6 CIDR association to VPC again
amazon.aws.ec2_vpc_net:
state: present
Expand All @@ -1510,10 +1525,10 @@
# now there should be one disassociated block and one associated block.
- result.vpc.ipv6_cidr_block_association_set | length == 2
- result.vpc.ipv6_cidr_block_association_set[0].association_id.startswith("vpc-cidr-assoc-")
- result.vpc.ipv6_cidr_block_association_set[0].ipv6_cidr_block | ansible.netcommon.ipv6
- result.vpc.ipv6_cidr_block_association_set[0].ipv6_cidr_block | ansible.utils.ipv6
- result.vpc.ipv6_cidr_block_association_set[0].ipv6_cidr_block_state.state in ["disassociated", "disassociating"]
- result.vpc.ipv6_cidr_block_association_set[1].association_id.startswith("vpc-cidr-assoc-")
- result.vpc.ipv6_cidr_block_association_set[1].ipv6_cidr_block | ansible.netcommon.ipv6
- result.vpc.ipv6_cidr_block_association_set[1].ipv6_cidr_block | ansible.utils.ipv6
- result.vpc.ipv6_cidr_block_association_set[1].ipv6_cidr_block_state.state in ["associated", "associating"]

# ============================================================
Expand Down
Loading