Debian Codegraph @

ansible_collections/amazon/aws/tests/integration/targets/ec2_vpc_nacl/tasks/ipv6.yml

raw
1 ---
2 - name: Test using IPv6
3 block:
4 # ============================================================
5
6 - name: Create ingress and egress rules using subnet names
7 amazon.aws.ec2_vpc_nacl:
8 vpc_id: "{{ vpc_ipv6_id }}"
9 name: "{{ nacl_name }}"
10 subnets:
11 - "{{ subnet_name }}-ipv6"
12 tags:
13 Created_by: "Ansible test {{ resource_prefix }}"
14 ingress:
15 - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22]
16 - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80]
17 - [300, "icmp", "allow", "0.0.0.0/0", 0, 8]
18 egress:
19 - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""]
20 state: "present"
21 register: nacl
22
23 - name: Assert that module returned the Network ACL id
24 ansible.builtin.assert:
25 that:
26 - nacl.nacl_id != ""
27
28 - name: Set fact for Network ACL ID
29 ansible.builtin.set_fact:
30 nacl_id: "{{ nacl.nacl_id }}"
31
32 - name: Add ipv6 entries
33 amazon.aws.ec2_vpc_nacl:
34 vpc_id: "{{ vpc_ipv6_id }}"
35 name: "{{ nacl_name }}"
36 subnets:
37 - "{{ subnet_name }}-ipv6"
38 tags:
39 Created_by: "Ansible test {{ resource_prefix }}"
40 ingress:
41 - [100, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 22, 22]
42 - [200, "tcp", "allow", "0.0.0.0/0", !!null "", !!null "", 80, 80]
43 - [205, "tcp", "allow", "::/0", !!null "", !!null "", 80, 80]
44 - [300, "icmp", "allow", "0.0.0.0/0", 0, 8]
45 - [305, "ipv6-icmp", "allow", "::/0", 0, 8]
46 egress:
47 - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""]
48 - [105, "all", "allow", "::/0", !!null "", !!null "", !!null "", !!null ""]
49 state: "present"
50 register: nacl
51
52 - name: Assert that module reported change while the Network ACL remained unchanged
53 ansible.builtin.assert:
54 that:
55 - nacl.changed
56 - nacl.nacl_id == nacl_id
57
58 - name: Get network ACL facts (test that it works with ipv6 entries)
59 amazon.aws.ec2_vpc_nacl_info:
60 nacl_ids:
61 - "{{ nacl_id }}"
62 register: nacl_facts
63
64 - name: Assert the nacl has the correct attributes
65 ansible.builtin.assert:
66 that:
67 - nacl_facts.nacls | length == 1
68 - nacl_facts.nacls[0].ingress | length == 5
69 - nacl_facts.nacls[0].egress | length == 2
70
71 - name: Purge ingress entries
72 amazon.aws.ec2_vpc_nacl:
73 vpc_id: "{{ vpc_ipv6_id }}"
74 name: "{{ nacl_name }}"
75 subnets:
76 - "{{ subnet_name }}-ipv6"
77 tags:
78 Created_by: "Ansible test {{ resource_prefix }}"
79 ingress: []
80 egress:
81 - [100, "all", "allow", "0.0.0.0/0", !!null "", !!null "", !!null "", !!null ""]
82 - [105, "all", "allow", "::/0", !!null "", !!null "", !!null "", !!null ""]
83 state: "present"
84 register: nacl
85
86 - name: Assert that module reported change while the Network ACL remained unchanged
87 ansible.builtin.assert:
88 that:
89 - nacl.changed
90 - nacl.nacl_id == nacl_id
91
92 - name: Purge egress entries
93 amazon.aws.ec2_vpc_nacl:
94 vpc_id: "{{ vpc_ipv6_id }}"
95 name: "{{ nacl_name }}"
96 subnets:
97 - "{{ subnet_name }}-ipv6"
98 tags:
99 Created_by: "Ansible test {{ resource_prefix }}"
100 ingress: []
101 egress: []
102 state: "present"
103 register: nacl
104
105 - name: Assert that module reported change
106 ansible.builtin.assert:
107 that:
108 - nacl.changed
109
110 - name: Get network ACL facts (test that removed entries are gone)
111 amazon.aws.ec2_vpc_nacl_info:
112 nacl_ids:
113 - "{{ nacl_id }}"
114 register: nacl_facts
115
116 - name: Assert the nacl has the correct attributes
117 ansible.builtin.assert:
118 that:
119 - nacl_facts.nacls | length == 1
120 - nacl_facts.nacls[0].ingress | length == 0
121 - nacl_facts.nacls[0].egress | length == 0
122
123 always:
124 - name: Remove network ACL
125 amazon.aws.ec2_vpc_nacl:
126 vpc_id: "{{ vpc_ipv6_id }}"
127 name: "{{ nacl_name }}"
128 state: absent
129 register: removed_acl
130 ignore_errors: true