Skip to content

Commit 6bc26b7

Browse files
authored
refactor(tests): use RFC-reserved addresses and prevent CIDR collisions (ansible-collections#3008)
SUMMARY Replace real public IP addresses with RFC-compliant reserved addresses (RFC 1918, RFC 5737 TEST-NET) in module documentation, test fixtures, and integration tests. Implement VPC CIDR randomization with dedicated third octets per test to eliminate collision risks during parallel test execution. ISSUE TYPE Test Pull Request COMPONENT NAME tests/integration, plugins/modules documentation ADDITIONAL INFORMATION IP Address Cleanup: Module documentation: Replaced AWS public IPs (52.x, 34.x, 44.x, 93.x, 55.x) with RFC 5737 TEST-NET addresses (198.51.100.x, 203.0.113.x) Test fixtures: Updated unit test fixtures to use RFC 1918 private addresses (10.x) Secrets: Replaced realistic pre-shared keys and version IDs with obvious example values CIDR Randomization Strategy: VPC CIDRs: Changed from 10.{{ 256 | random(seed=...) }}.0.0/16 to dedicated /22 blocks per test Third octet assignment: Each test gets a unique range (0, 4, 8, 12, ..., 152) to guarantee zero overlap Second octet randomization: Maintains 10.{{ 256 | random(seed=resource_prefix) }} for test isolation Benefit: Orphaned VPCs can be traced to source test via third octet Test Assignments: autoscaling_instance: 10.X.0.0/22 autoscaling_group: 10.X.148.0/22 autoscaling_instance_refresh: 10.X.152.0/22 cloudformation through setup_ec2_instance_env: 10.X.4-144.0/22 (increments of 4) This eliminates the small collision risk when parallel test runs previously used overlapping address space. Assisted-by: Claude Sonnet 4.5 Reviewed-by: Alina Buzachis
1 parent 2f7def0 commit 6bc26b7

75 files changed

Lines changed: 313 additions & 264 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
trivial:
3+
- integration tests - replace hard-coded VPC and subnet CIDRs with randomized values using dedicated third octets per test to prevent parallel test collisions (https://github.com/ansible-collections/amazon.aws/pull/3008).
4+
5+
minor_changes:
6+
- backup_plan - replace realistic version IDs with example UUID format in documentation (https://github.com/ansible-collections/amazon.aws/pull/3008).
7+
- backup_plan_info - replace realistic version IDs with example UUID format in documentation (https://github.com/ansible-collections/amazon.aws/pull/3008).
8+
- ec2_eip - replace AWS public IPs with RFC 5737 TEST-NET addresses in documentation examples (https://github.com/ansible-collections/amazon.aws/pull/3008).
9+
- ec2_eni_info - use RFC 1918 private addresses in documentation examples (https://github.com/ansible-collections/amazon.aws/pull/3008).
10+
- ec2_instance - use RFC 5737 TEST-NET addresses in documentation examples (https://github.com/ansible-collections/amazon.aws/pull/3008).
11+
- ec2_instance_info - use RFC 5737 TEST-NET addresses in documentation examples (https://github.com/ansible-collections/amazon.aws/pull/3008).
12+
- ec2_key_info - replace realistic SSH fingerprint with example value in documentation (https://github.com/ansible-collections/amazon.aws/pull/3008).
13+
- ec2_metadata_facts - use RFC 5737 TEST-NET addresses in documentation examples (https://github.com/ansible-collections/amazon.aws/pull/3008).
14+
- ec2_vpc_dhcp_option - use public DNS servers (8.8.4.4, 8.8.8.8) instead of RFC 5737 addresses for DNS examples (https://github.com/ansible-collections/amazon.aws/pull/3008).
15+
- ec2_vpc_nat_gateway - use RFC 5737 TEST-NET addresses in documentation examples (https://github.com/ansible-collections/amazon.aws/pull/3008).
16+
- ec2_vpc_nat_gateway_info - use RFC 5737 TEST-NET addresses in documentation examples (https://github.com/ansible-collections/amazon.aws/pull/3008).
17+
- ec2_vpc_vpn - replace realistic pre-shared key with obvious example value in documentation (https://github.com/ansible-collections/amazon.aws/pull/3008).
18+
- ec2_vpc_vpn - use RFC 5737 TEST-NET addresses in documentation examples (https://github.com/ansible-collections/amazon.aws/pull/3008).
19+
- ec2_vpc_vpn_info - use RFC 5737 TEST-NET addresses in documentation examples (https://github.com/ansible-collections/amazon.aws/pull/3008).
20+
- route53 - use RFC 5737 TEST-NET addresses in documentation examples (https://github.com/ansible-collections/amazon.aws/pull/3008).
21+
- route53_health_check - use RFC 5737 TEST-NET addresses in documentation examples (https://github.com/ansible-collections/amazon.aws/pull/3008).

plugins/modules/backup_plan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@
232232
description: Version ID of the backup plan.
233233
returned: always
234234
type: str
235-
sample: ODM3MjVjNjItYWFkOC00NjExLWIwZTYtZDNiNGI5M2I0ZTY1
235+
sample: 01234567-89ab-cdef-0123-456789abcdef
236236
backup_plan:
237237
description: Backup plan details.
238238
returned: on create/update

plugins/modules/backup_plan_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
description: Version id of the backup plan
8484
returned: always
8585
type: str
86-
sample: 'A2AiAAAmAAAtAxAxAA00AAa0AAAxAxAtA0AmAAA4NDY1ZTZl'
86+
sample: '01234567-89ab-cdef-0123-456789abcdef'
8787
backup_plan:
8888
returned: always
8989
description: Detailed information about the backup plan.

plugins/modules/ec2_eip.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,29 +106,29 @@
106106
- name: associate an elastic IP with an instance
107107
amazon.aws.ec2_eip:
108108
device_id: i-1212f003
109-
ip: 93.184.216.119
109+
ip: 203.0.113.1
110110
111111
- name: associate an elastic IP with a device
112112
amazon.aws.ec2_eip:
113113
device_id: eni-c8ad70f3
114-
ip: 93.184.216.119
114+
ip: 203.0.113.1
115115
116116
- name: associate an elastic IP with a device and allow reassociation
117117
amazon.aws.ec2_eip:
118118
device_id: eni-c8ad70f3
119-
public_ip: 93.184.216.119
119+
public_ip: 203.0.113.1
120120
allow_reassociation: true
121121
122122
- name: disassociate an elastic IP from an instance
123123
amazon.aws.ec2_eip:
124124
device_id: i-1212f003
125-
ip: 93.184.216.119
125+
ip: 203.0.113.1
126126
state: absent
127127
128128
- name: disassociate an elastic IP with a device
129129
amazon.aws.ec2_eip:
130130
device_id: eni-c8ad70f3
131-
ip: 93.184.216.119
131+
ip: 203.0.113.1
132132
state: absent
133133
134134
- name: allocate a new elastic IP and associate it with an instance
@@ -214,13 +214,13 @@
214214
215215
- name: Modify reverse DNS record of an existing EIP
216216
amazon.aws.ec2_eip:
217-
public_ip: 44.224.84.105
217+
public_ip: 203.0.113.2
218218
domain_name: test-domain.xyz
219219
state: present
220220
221221
- name: Remove reverse DNS record of an existing EIP
222222
amazon.aws.ec2_eip:
223-
public_ip: 44.224.84.105
223+
public_ip: 203.0.113.2
224224
domain_name: ""
225225
state: present
226226
"""
@@ -235,7 +235,7 @@
235235
description: An elastic ip address.
236236
returned: on success
237237
type: str
238-
sample: 52.88.159.209
238+
sample: 203.0.113.1
239239
update_reverse_dns_record_result:
240240
description: Information about result of update reverse dns record operation.
241241
returned: When O(domain_name) is specified.
@@ -275,7 +275,7 @@
275275
description: The public IP address.
276276
returned: always
277277
type: str
278-
sample: "11.22.33.44"
278+
sample: "203.0.113.1"
279279
"""
280280

281281
from typing import Any

plugins/modules/ec2_eni_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
association_id: "eipassoc-8sdf123",
6161
ip_owner_id: "123456789012",
6262
public_dns_name: "ec2-52-1-0-63.compute-1.amazonaws.com",
63-
public_ip: "52.1.0.63"
63+
public_ip: "203.0.113.10"
6464
}
6565
attachment:
6666
description: Info about attached ec2 instance.

plugins/modules/ec2_instance.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@
604604
security_group: default
605605
tower_callback:
606606
# IP or hostname of tower server
607-
tower_address: 1.2.3.4
607+
tower_address: 192.0.2.1
608608
job_template_id: 876
609609
host_config_key: '[secret config key goes here]'
610610
network_interfaces:
@@ -700,9 +700,9 @@
700700
subnet_id: subnet-0123456
701701
private_ip_addresses:
702702
- primary: true
703-
private_ip_address: 168.50.4.239
703+
private_ip_address: 192.168.4.239
704704
- primary: false
705-
private_ip_address: 168.50.4.237
705+
private_ip_address: 192.168.4.237
706706
state: present
707707
tags:
708708
foo: bar
@@ -974,7 +974,7 @@
974974
description: The public IP address or Elastic IP address bound to the network interface.
975975
returned: always
976976
type: str
977-
sample: 1.2.3.4
977+
sample: 203.0.113.1
978978
attachment:
979979
description: The network interface attachment.
980980
returned: always
@@ -1096,7 +1096,7 @@
10961096
description: The public IP address or Elastic IP address bound to the network interface.
10971097
returned: always
10981098
type: str
1099-
sample: 1.2.3.4
1099+
sample: 203.0.113.1
11001100
primary:
11011101
description: Indicates whether this IPv4 address is the primary private IP address of the network interface.
11021102
returned: always
@@ -1233,7 +1233,7 @@
12331233
description: The public IPv4 address assigned to the instance
12341234
returned: always
12351235
type: str
1236-
sample: 52.0.0.1
1236+
sample: 203.0.113.12
12371237
root_device_name:
12381238
description: The device name of the root device
12391239
returned: always

plugins/modules/ec2_instance_info.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@
337337
description: The public IP address or Elastic IP address bound to the network interface.
338338
returned: always
339339
type: str
340-
sample: 1.2.3.4
340+
sample: 203.0.113.1
341341
attachment:
342342
description: The network interface attachment.
343343
returned: always
@@ -459,7 +459,7 @@
459459
description: The public IP address or Elastic IP address bound to the network interface.
460460
returned: always
461461
type: str
462-
sample: 1.2.3.4
462+
sample: 203.0.113.1
463463
primary:
464464
description: Indicates whether this IPv4 address is the primary private IP address of the network interface.
465465
returned: always
@@ -571,7 +571,7 @@
571571
description: The public IPv4 address assigned to the instance.
572572
returned: always
573573
type: str
574-
sample: 52.0.0.1
574+
sample: 203.0.113.11
575575
root_device_name:
576576
description: The device name of the root device.
577577
returned: always

plugins/modules/ec2_key_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
- name: Retrieve EC2 key pair by fingerprint
6262
amazon.aws.ec2_key_info:
6363
filters:
64-
fingerprint: "1bSd8jVye3In5oF4zZI4o8BcXfdbYN+daCt9O1fh3Qk="
64+
fingerprint: "EXAMPLE1234567890abcdefghijklmnop="
6565
"""
6666

6767
RETURN = r"""

plugins/modules/ec2_metadata_facts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
ansible_ec2_network_interfaces_macs_mac_address_public_ipv4s:
350350
description: The Elastic IP addresses associated with the interface. There may be multiple IPv4 addresses on an instance.
351351
type: str
352-
sample: "1.2.3.4"
352+
sample: "203.0.113.1"
353353
ansible_ec2_network_interfaces_macs_mac_address_security_group_ids:
354354
description: The IDs of the security groups to which the network interface belongs. Returned only for instances launched into a VPC.
355355
type: str
@@ -410,7 +410,7 @@
410410
ansible_ec2_public_ipv4:
411411
description: The public IPv4 address. If an Elastic IP address is associated with the instance, the value returned is the Elastic IP address.
412412
type: str
413-
sample: "1.2.3.4"
413+
sample: "203.0.113.1"
414414
ansible_ec2_public_key:
415415
description: Public key. Only available if supplied at instance launch time.
416416
type: str

plugins/modules/ec2_vpc_dhcp_option.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,12 @@
202202
inherit_existing: true
203203
delete_old: false
204204
205-
## Create a DHCP option set with 4.4.4.4 and 8.8.8.8 as the specified DNS servers, with tags
205+
## Create a DHCP option set with 8.8.4.4 and 8.8.8.8 as the specified DNS servers, with tags
206206
## but do not assign to a VPC
207207
- amazon.aws.ec2_vpc_dhcp_option:
208208
region: us-east-1
209209
dns_servers:
210-
- 4.4.4.4
210+
- 8.8.4.4
211211
- 8.8.8.8
212212
tags:
213213
Name: google servers
@@ -217,7 +217,7 @@
217217
- amazon.aws.ec2_vpc_dhcp_option:
218218
region: us-east-1
219219
dns_servers:
220-
- 4.4.4.4
220+
- 8.8.4.4
221221
- 8.8.8.8
222222
tags:
223223
Name: google servers

0 commit comments

Comments
 (0)