diff --git a/tests/integration/targets/lookup_aws_service_ip_ranges/aliases b/tests/integration/targets/lookup_aws_service_ip_ranges/aliases new file mode 100644 index 00000000000..4ef4b2067d0 --- /dev/null +++ b/tests/integration/targets/lookup_aws_service_ip_ranges/aliases @@ -0,0 +1 @@ +cloud/aws diff --git a/tests/integration/targets/lookup_aws_service_ip_ranges/tasks/main.yaml b/tests/integration/targets/lookup_aws_service_ip_ranges/tasks/main.yaml new file mode 100644 index 00000000000..70551c36fcc --- /dev/null +++ b/tests/integration/targets/lookup_aws_service_ip_ranges/tasks/main.yaml @@ -0,0 +1,103 @@ +- name: lookup range with no arguments + set_fact: + no_params: "{{ lookup('amazon.aws.aws_service_ip_ranges') }}" + +- name: assert that we're returned a single string + assert: + that: + - no_params is defined + - no_params is string + +- name: lookup range with wantlist + set_fact: + want_list: "{{ lookup('amazon.aws.aws_service_ip_ranges', wantlist=True) }}" + +- name: assert that we're returned a list + assert: + that: + - want_list is defined + - want_list is iterable + - want_list is not string + - want_list | length > 1 + - want_list[0] | ansible.netcommon.ipv4 + +- name: lookup range with service + set_fact: + s3_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', service='S3', wantlist=True) }}" + +- name: assert that we're returned a list + assert: + that: + - s3_ips is defined + - s3_ips is iterable + - s3_ips is not string + - s3_ips | length > 1 + - s3_ips[0] | ansible.netcommon.ipv4 + +- name: lookup range with a different service + set_fact: + route53_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', service='ROUTE53_HEALTHCHECKS', wantlist=True) }}" + +- name: assert that we're returned a list + assert: + that: + - route53_ips is defined + - route53_ips is iterable + - route53_ips is not string + - route53_ips | length > 1 + - route53_ips[0] | ansible.netcommon.ipv4 + +- name: assert that service IPs don't overlap + assert: + that: + - route53_ips | intersect(s3_ips) | length == 0 + +- name: lookup range with region + set_fact: + us_east_1_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', region='us-east-1', wantlist=True) }}" + +- name: assert that we're returned a list + assert: + that: + - us_east_1_ips is defined + - 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 + +- name: lookup range with a different region + set_fact: + eu_central_1_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', region='eu-central-1', wantlist=True) }}" + +- name: assert that we're returned a list + assert: + that: + - eu_central_1_ips is defined + - 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 + +- name: assert that regional IPs don't overlap + assert: + that: + - eu_central_1_ips | intersect(us_east_1_ips) | length == 0 + +- name: lookup range with service and region + set_fact: + s3_us_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', region='us-east-1', service='S3', wantlist=True) }}" + +- name: assert that we're returned a list + assert: + that: + - s3_us_ips is defined + - s3_us_ips is iterable + - s3_us_ips is not string + - s3_us_ips | length > 1 + - s3_us_ips[0] | ansible.netcommon.ipv4 + +- name: assert that the regional service IPs are a subset of the regional IPs and service IPs. + assert: + that: + - ( s3_us_ips | intersect(us_east_1_ips) | length ) == ( s3_us_ips | length ) + - ( s3_us_ips | intersect(s3_ips) | length ) == ( s3_us_ips | length )