Skip to content

Commit

Permalink
ipv4, ipv6, ipsubnet have moved from ansible.netcommon to ansible.uti…
Browse files Browse the repository at this point in the history
…ls (#635) (#661)

[PR #635/0db6ac10 backport][stable-3] ipv4, ipv6, ipsubnet have moved from ansible.netcommon to ansible.utils

This is a backport of PR #635 as merged into main (0db6ac1).
SUMMARY

This is a maintenance task to migrate from ansible.netcommon to ansible.utils. I was trying to fix an issue in that module, but I was told the functions have moved to ansible.utils. See ansible-collections/ansible.netcommon#362 (comment)

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

Existing integration tests that use the ansible.netcommon module. No module uses netcommon, only integration tests.
ADDITIONAL INFORMATION
  • Loading branch information
patchback[bot] authored Feb 9, 2022
1 parent d139a38 commit 0d4a56a
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mock
pytest-xdist
# We should avoid these two modules with py3
pytest-mock
# Needed for ansible.netcommon.ipaddr in tests
# Needed for ansible.utils.ipaddr in tests
netaddr
# Sometimes needed where we don't have features we need in modules
awscli
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ boto
boto3
botocore

# netaddr is needed for ansible.netcommon.ipv6
# netaddr is needed for ansible.utils.ipv6
netaddr
virtualenv
# Sometimes needed where we don't have features we need in modules
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/targets/ec2_eni/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
region: "{{ aws_region }}"

collections:
- ansible.netcommon
- ansible.utils
- community.aws

block:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
- _interface_0.private_dns_name is string
- _interface_0.private_dns_name.endswith("ec2.internal")
- '"private_ip_address" in _interface_0'
- _interface_0.private_ip_address | ansible.netcommon.ipaddr
- _interface_0.private_ip_address | ansible.utils.ipaddr
- _interface_0.private_ip_address == ip_1
- '"private_ip_addresses" in _interface_0'
- _interface_0.private_ip_addresses | length == 1
Expand Down Expand Up @@ -178,7 +178,7 @@
- _interface_0.private_dns_name is string
- _interface_0.private_dns_name.endswith("ec2.internal")
- '"private_ip_address" in _interface_0'
- _interface_0.private_ip_address | ansible.netcommon.ipaddr
- _interface_0.private_ip_address | ansible.utils.ipaddr
- _interface_0.private_ip_address == ip_5
- '"private_ip_addresses" in _interface_0'
- _interface_0.private_ip_addresses | length == 1
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/targets/ec2_vpc_net/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
- '"instance_tenancy" in result.vpc'
- 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 ["associated", "associating"]
- '"is_default" in result.vpc'
- '"state" in result.vpc'
Expand Down Expand Up @@ -136,7 +136,7 @@
- '"instance_tenancy" in result.vpc'
- 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 ["associated", "associating"]
- '"is_default" in result.vpc'
- '"state" in result.vpc'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
- want_list is iterable
- want_list is not string
- want_list | length > 1
- want_list[0] | ansible.netcommon.ipv4
- want_list[0] | ansible.utils.ipv4
- want_ipv6_list is defined
- want_ipv6_list is iterable
- want_ipv6_list is not string
- want_ipv6_list | length > 1
- want_ipv6_list[0] | ansible.netcommon.ipv6
- want_ipv6_list[0] | ansible.utils.ipv6


- name: lookup range with service
Expand All @@ -40,12 +40,12 @@
- s3_ips is iterable
- s3_ips is not string
- s3_ips | length > 1
- s3_ips[0] | ansible.netcommon.ipv4
- s3_ips[0] | ansible.utils.ipv4
- s3_ipv6s is defined
- s3_ipv6s is iterable
- s3_ipv6s is not string
- s3_ipv6s | length > 1
- s3_ipv6s[0] | ansible.netcommon.ipv6
- s3_ipv6s[0] | ansible.utils.ipv6

- name: lookup range with a different service
set_fact:
Expand All @@ -59,12 +59,12 @@
- route53_ips is iterable
- route53_ips is not string
- route53_ips | length > 1
- route53_ips[0] | ansible.netcommon.ipv4
- route53_ips[0] | ansible.utils.ipv4
- route53_ipv6s is defined
- route53_ipv6s is iterable
- route53_ipv6s is not string
- route53_ipv6s | length > 1
- route53_ipv6s[0] | ansible.netcommon.ipv6
- route53_ipv6s[0] | ansible.utils.ipv6


- name: assert that service IPV4s and IPV6s do not overlap
Expand All @@ -88,12 +88,12 @@
- us_east_1_ips is iterable
- us_east_1_ips is not string
- us_east_1_ips | length > 1
- us_east_1_ips[0] | ansible.netcommon.ipv4
- us_east_1_ips[0] | ansible.utils.ipv4
- us_east_1_ipv6s is defined
- us_east_1_ipv6s is iterable
- us_east_1_ipv6s is not string
- us_east_1_ipv6s | length > 1
- us_east_1_ipv6s[0] | ansible.netcommon.ipv6
- us_east_1_ipv6s[0] | ansible.utils.ipv6

- name: lookup range with a different region
set_fact:
Expand All @@ -107,12 +107,12 @@
- eu_central_1_ips is iterable
- eu_central_1_ips is not string
- eu_central_1_ips | length > 1
- eu_central_1_ips[0] | ansible.netcommon.ipv4
- eu_central_1_ips[0] | ansible.utils.ipv4
- eu_central_1_ipv6s is defined
- eu_central_1_ipv6s is iterable
- eu_central_1_ipv6s is not string
- eu_central_1_ipv6s | length > 1
- eu_central_1_ipv6s[0] | ansible.netcommon.ipv6
- eu_central_1_ipv6s[0] | ansible.utils.ipv6

- name: assert that regional IPs don't overlap
assert:
Expand All @@ -132,12 +132,12 @@
- s3_us_ips is iterable
- s3_us_ips is not string
- s3_us_ips | length > 1
- s3_us_ips[0] | ansible.netcommon.ipv4
- s3_us_ips[0] | ansible.utils.ipv4
- s3_us_ipv6s is defined
- s3_us_ipv6s is iterable
- s3_us_ipv6s is not string
- s3_us_ipv6s | length > 1
- s3_us_ipv6s[0] | ansible.netcommon.ipv6
- s3_us_ipv6s[0] | ansible.utils.ipv6

- name: assert that the regional service IPs are a subset of the regional IPs and service IPs.
assert:
Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
integration_tests_dependencies:
- ansible.windows
- ansible.netcommon # ipv6 filter
- ansible.utils # ipv6 filter
unit_tests_dependencies: []

0 comments on commit 0d4a56a

Please sign in to comment.