From 2c7557df5e718a3dd7d5c1eadb7b1af958c702ed Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Fri, 6 Aug 2021 10:43:00 +0200 Subject: [PATCH 1/6] Remove code testing for unsupported versions of boto3/botocore --- changelogs/fragments/675-boto3-minimums.yml | 26 +++++++++++++ plugins/modules/aws_eks_cluster.py | 8 ---- plugins/modules/cloudformation_stack_set.py | 2 - plugins/modules/dynamodb_table.py | 2 - plugins/modules/dynamodb_ttl.py | 4 -- plugins/modules/ec2_ami_copy.py | 1 - plugins/modules/ec2_asg.py | 16 -------- plugins/modules/ec2_launch_template.py | 3 -- plugins/modules/ec2_transit_gateway.py | 3 -- plugins/modules/ec2_transit_gateway_info.py | 3 -- plugins/modules/ec2_vpc_peer.py | 2 - plugins/modules/ecs_ecr.py | 1 - plugins/modules/ecs_service.py | 41 +++------------------ plugins/modules/ecs_task.py | 36 ------------------ plugins/modules/ecs_taskdefinition.py | 8 ---- plugins/modules/efs.py | 21 ++--------- plugins/modules/efs_info.py | 4 +- plugins/modules/elb_target_group.py | 10 ----- plugins/modules/iam_role.py | 10 ----- plugins/modules/lambda.py | 6 +-- plugins/modules/rds_instance.py | 3 -- plugins/modules/sqs_queue.py | 2 +- 22 files changed, 39 insertions(+), 173 deletions(-) create mode 100644 changelogs/fragments/675-boto3-minimums.yml diff --git a/changelogs/fragments/675-boto3-minimums.yml b/changelogs/fragments/675-boto3-minimums.yml new file mode 100644 index 00000000000..359636714d4 --- /dev/null +++ b/changelogs/fragments/675-boto3-minimums.yml @@ -0,0 +1,26 @@ +major_changes: +- community.aws collection - The community.aws collection has dropped support for ``botocore<1.16.0`` and ``boto3<1.13.0`` (https://github.com/ansible-collections/community.aws/pull/675). + Most modules will continue to work with older versions of the AWS SDK, however compatability with older versions of the SDK is not guaranteed and will not be tested. + When using older versions of the SDK a warning will be emitted by Ansible (https://github.com/ansible-collections/amazon.aws/pull/442). +minor_changes: +- aws_eks_cluster - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- cloudformation_stack_set - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- dynamodb_table - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- dynamodb_ttl - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- ec2_ami_copy - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- ec2_asg - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- ec2_launch_template - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- ec2_transit_gateway - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- ec2_transit_gateway_info - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- ec2_vpc_peer - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- ecs_ecr - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- ecs_service - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- ecs_task - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- ecs_taskdefinition - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- efs - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- efs_info - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- elb_target_group - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- iam_role - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- lambda - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- rds_instance - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). +- sqs_queue - Tests for compatability with older versions of the AWS SDKs have been removed (https://github.com/ansible-collections/community.aws/pull/675). diff --git a/plugins/modules/aws_eks_cluster.py b/plugins/modules/aws_eks_cluster.py index 3d8f2696d5f..64627377c41 100644 --- a/plugins/modules/aws_eks_cluster.py +++ b/plugins/modules/aws_eks_cluster.py @@ -281,14 +281,6 @@ def main(): supports_check_mode=True, ) - if not module.botocore_at_least("1.10.32"): - module.fail_json(msg='aws_eks_cluster module requires botocore >= 1.10.32') - - if (not module.botocore_at_least("1.12.38") and - module.params.get('state') == 'absent' and - module.params.get('wait')): - module.fail_json(msg='aws_eks_cluster: wait=yes when state=absent requires botocore >= 1.12.38') - client = module.client('eks') if module.params.get('state') == 'present': diff --git a/plugins/modules/cloudformation_stack_set.py b/plugins/modules/cloudformation_stack_set.py index 72b6aa05bef..b10addf7485 100644 --- a/plugins/modules/cloudformation_stack_set.py +++ b/plugins/modules/cloudformation_stack_set.py @@ -529,8 +529,6 @@ def main(): mutually_exclusive=[['template_url', 'template', 'template_body']], supports_check_mode=True ) - if not (module.boto3_at_least('1.6.0') and module.botocore_at_least('1.10.26')): - module.fail_json(msg="Boto3 or botocore version is too low. This module requires at least boto3 1.6 and botocore 1.10.26") # Wrap the cloudformation client methods that this module uses with # automatic backoff / retry for throttling error codes diff --git a/plugins/modules/dynamodb_table.py b/plugins/modules/dynamodb_table.py index db9710f12d6..b23c443cac9 100644 --- a/plugins/modules/dynamodb_table.py +++ b/plugins/modules/dynamodb_table.py @@ -494,8 +494,6 @@ def main(): if module.params.get('tags'): try: boto3_dynamodb = module.client('dynamodb') - if not hasattr(boto3_dynamodb, 'tag_resource'): - module.fail_json(msg='boto3 connection does not have tag_resource(), likely due to using an old version') boto3_sts = module.client('sts') except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: module.fail_json_aws(e, msg='Failed to connect to AWS') diff --git a/plugins/modules/dynamodb_ttl.py b/plugins/modules/dynamodb_ttl.py index 490a948f9a9..2bdd9a21d45 100644 --- a/plugins/modules/dynamodb_ttl.py +++ b/plugins/modules/dynamodb_ttl.py @@ -120,10 +120,6 @@ def main(): argument_spec=argument_spec, ) - if not module.botocore_at_least('1.5.24'): - # TTL was added in 1.5.24 - module.fail_json(msg='Found botocore in version {0}, but >= {1} is required for TTL support'.format(botocore.__version__, '1.5.24')) - try: dbclient = module.client('dynamodb') except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: diff --git a/plugins/modules/ec2_ami_copy.py b/plugins/modules/ec2_ami_copy.py index 15acfe4e4a9..e5628b00034 100644 --- a/plugins/modules/ec2_ami_copy.py +++ b/plugins/modules/ec2_ami_copy.py @@ -212,7 +212,6 @@ def main(): tag_equality=dict(type='bool', default=False)) module = AnsibleAWSModule(argument_spec=argument_spec) - # TODO: Check botocore version ec2 = module.client('ec2') copy_image(module, ec2) diff --git a/plugins/modules/ec2_asg.py b/plugins/modules/ec2_asg.py index 59e74040d64..662c23873b1 100644 --- a/plugins/modules/ec2_asg.py +++ b/plugins/modules/ec2_asg.py @@ -1825,22 +1825,6 @@ def main(): ] ) - if ( - module.params.get('max_instance_lifetime') is not None - and not module.botocore_at_least('1.13.21') - ): - module.fail_json( - msg='Botocore needs to be version 1.13.21 or higher to use max_instance_lifetime.' - ) - - if ( - module.params.get('mixed_instances_policy') is not None - and not module.botocore_at_least('1.12.45') - ): - module.fail_json( - msg='Botocore needs to be version 1.12.45 or higher to use mixed_instances_policy.' - ) - state = module.params.get('state') replace_instances = module.params.get('replace_instances') replace_all_instances = module.params.get('replace_all_instances') diff --git a/plugins/modules/ec2_launch_template.py b/plugins/modules/ec2_launch_template.py index cebae8b2fec..e96049fa347 100644 --- a/plugins/modules/ec2_launch_template.py +++ b/plugins/modules/ec2_launch_template.py @@ -719,9 +719,6 @@ def main(): supports_check_mode=True ) - if not module.boto3_at_least('1.6.0'): - module.fail_json(msg="ec2_launch_template requires boto3 >= 1.6.0") - for interface in (module.params.get('network_interfaces') or []): if interface.get('ipv6_addresses'): interface['ipv6_addresses'] = [{'ipv6_address': x} for x in interface['ipv6_addresses']] diff --git a/plugins/modules/ec2_transit_gateway.py b/plugins/modules/ec2_transit_gateway.py index 8435491388a..c013ea67379 100644 --- a/plugins/modules/ec2_transit_gateway.py +++ b/plugins/modules/ec2_transit_gateway.py @@ -245,9 +245,6 @@ def __init__(self, module, results): self._connection = self._module.client('ec2') self._check_mode = self._module.check_mode - if not hasattr(self._connection, 'describe_transit_gateways'): - self._module.fail_json(msg='transit gateway module requires boto3 >= 1.9.52') - def process(self): """ Process the request based on state parameter . state = present will search for an existing tgw based and return the object data. diff --git a/plugins/modules/ec2_transit_gateway_info.py b/plugins/modules/ec2_transit_gateway_info.py index c23289eaa1c..024aa5dcec9 100644 --- a/plugins/modules/ec2_transit_gateway_info.py +++ b/plugins/modules/ec2_transit_gateway_info.py @@ -183,9 +183,6 @@ def __init__(self, module, results): self._connection = self._module.client('ec2') self._check_mode = self._module.check_mode - if not hasattr(self._connection, 'describe_transit_gateways'): - self._module.fail_json(msg='transit gateway module requires boto3 >= 1.9.52') - @AWSRetry.exponential_backoff() def describe_transit_gateways(self): """ diff --git a/plugins/modules/ec2_vpc_peer.py b/plugins/modules/ec2_vpc_peer.py index c45a003903c..b651b173ce4 100644 --- a/plugins/modules/ec2_vpc_peer.py +++ b/plugins/modules/ec2_vpc_peer.py @@ -423,8 +423,6 @@ def create_peer_connection(client, module): params['VpcId'] = module.params.get('vpc_id') params['PeerVpcId'] = module.params.get('peer_vpc_id') if module.params.get('peer_region'): - if not module.botocore_at_least('1.8.6'): - module.fail_json(msg="specifying peer_region parameter requires botocore >= 1.8.6") params['PeerRegion'] = module.params.get('peer_region') if module.params.get('peer_owner_id'): params['PeerOwnerId'] = str(module.params.get('peer_owner_id')) diff --git a/plugins/modules/ecs_ecr.py b/plugins/modules/ecs_ecr.py index a20262956da..2b22147212b 100644 --- a/plugins/modules/ecs_ecr.py +++ b/plugins/modules/ecs_ecr.py @@ -76,7 +76,6 @@ scan_on_push: description: - if C(true), images are scanned for known vulnerabilities after being pushed to the repository. - - I(scan_on_push) requires botocore >= 1.13.3 required: false default: false type: bool diff --git a/plugins/modules/ecs_service.py b/plugins/modules/ecs_service.py index 89cfaf486aa..590276e0ab1 100644 --- a/plugins/modules/ecs_service.py +++ b/plugins/modules/ecs_service.py @@ -130,7 +130,6 @@ network_configuration: description: - Network configuration of the service. Only applicable for task definitions created with I(network_mode=awsvpc). - - I(assign_public_ip) requires botocore >= 1.8.4 type: dict suboptions: subnets: @@ -146,7 +145,6 @@ assign_public_ip: description: - Whether the task's elastic network interface receives a public IP address. - - This option requires botocore >= 1.8.4. type: bool launch_type: description: @@ -164,7 +162,6 @@ health_check_grace_period_seconds: description: - Seconds to wait before health checking the freshly added/updated services. - - This option requires botocore >= 1.8.20. required: false type: int service_registries: @@ -516,13 +513,10 @@ def format_network_configuration(self, network_config): self.module.fail_json_aws(e, msg="Couldn't look up security groups") result['securityGroups'] = groups if network_config['assign_public_ip'] is not None: - if self.module.botocore_at_least('1.8.4'): - if network_config['assign_public_ip'] is True: - result['assignPublicIp'] = "ENABLED" - else: - result['assignPublicIp'] = "DISABLED" + if network_config['assign_public_ip'] is True: + result['assignPublicIp'] = "ENABLED" else: - self.module.fail_json(msg='botocore needs to be version 1.8.4 or higher to use assign_public_ip in network_configuration') + result['assignPublicIp'] = "DISABLED" return dict(awsvpcConfiguration=result) def find_in_array(self, array_of_services, service_name, field_name='serviceArn'): @@ -640,16 +634,9 @@ def jsonize(self, service): def delete_service(self, service, cluster=None): return self.ecs.delete_service(cluster=cluster, service=service) - def ecs_api_handles_network_configuration(self): - # There doesn't seem to be a nice way to inspect botocore to look - # for attributes (and networkConfiguration is not an explicit argument - # to e.g. ecs.run_task, it's just passed as a keyword argument) - return self.module.botocore_at_least('1.7.44') - def health_check_setable(self, params): load_balancers = params.get('loadBalancers', []) - # check if botocore (and thus boto3) is new enough for using the healthCheckGracePeriodSeconds parameter - return len(load_balancers) > 0 and self.module.botocore_at_least('1.8.20') + return len(load_balancers) > 0 def main(): @@ -710,8 +697,6 @@ def main(): service_mgr = EcsServiceManager(module) if module.params['network_configuration']: - if not service_mgr.ecs_api_handles_network_configuration(): - module.fail_json(msg='botocore needs to be version 1.7.44 or higher to use network configuration') network_configuration = service_mgr.format_network_configuration(module.params['network_configuration']) else: network_configuration = None @@ -729,16 +714,6 @@ def main(): results = dict(changed=False) - if module.params['launch_type']: - if not module.botocore_at_least('1.8.4'): - module.fail_json(msg='botocore needs to be version 1.8.4 or higher to use launch_type') - if module.params['force_new_deployment']: - if not module.botocore_at_least('1.8.4'): - module.fail_json(msg='botocore needs to be version 1.8.4 or higher to use force_new_deployment') - if module.params['health_check_grace_period_seconds']: - if not module.botocore_at_least('1.8.20'): - module.fail_json(msg='botocore needs to be version 1.8.20 or higher to use health_check_grace_period_seconds') - if module.params['state'] == 'present': matching = False @@ -773,15 +748,11 @@ def main(): # check various parameters and boto versions and give a helpful error in boto is not new enough for feature if module.params['scheduling_strategy']: - if not module.botocore_at_least('1.10.37'): - module.fail_json(msg='botocore needs to be version 1.10.37 or higher to use scheduling_strategy') - elif (existing['schedulingStrategy']) != module.params['scheduling_strategy']: + if (existing['schedulingStrategy']) != module.params['scheduling_strategy']: module.fail_json(msg="It is not possible to update the scheduling strategy of an existing service") if module.params['service_registries']: - if not module.botocore_at_least('1.9.15'): - module.fail_json(msg='botocore needs to be version 1.9.15 or higher to use service_registries') - elif (existing['serviceRegistries'] or []) != serviceRegistries: + if (existing['serviceRegistries'] or []) != serviceRegistries: module.fail_json(msg="It is not possible to update the service registries of an existing service") if (existing['loadBalancers'] or []) != loadBalancers: diff --git a/plugins/modules/ecs_task.py b/plugins/modules/ecs_task.py index 411121372cf..6bcc3c5d850 100644 --- a/plugins/modules/ecs_task.py +++ b/plugins/modules/ecs_task.py @@ -63,7 +63,6 @@ network_configuration: description: - Network configuration of the service. Only applicable for task definitions created with I(network_mode=awsvpc). - - I(assign_public_ip) requires botocore >= 1.8.4 type: dict suboptions: assign_public_ip: @@ -334,34 +333,10 @@ def stop_task(self, cluster, task): response = self.ecs.stop_task(cluster=cluster, task=task) return response['task'] - def ecs_api_handles_launch_type(self): - # There doesn't seem to be a nice way to inspect botocore to look - # for attributes (and networkConfiguration is not an explicit argument - # to e.g. ecs.run_task, it's just passed as a keyword argument) - return self.module.botocore_at_least('1.8.4') - def ecs_task_long_format_enabled(self): account_support = self.ecs.list_account_settings(name='taskLongArnFormat', effectiveSettings=True) return account_support['settings'][0]['value'] == 'enabled' - def ecs_api_handles_tags(self): - # There doesn't seem to be a nice way to inspect botocore to look - # for attributes (and networkConfiguration is not an explicit argument - # to e.g. ecs.run_task, it's just passed as a keyword argument) - return self.module.botocore_at_least('1.12.46') - - def ecs_api_handles_network_configuration(self): - # There doesn't seem to be a nice way to inspect botocore to look - # for attributes (and networkConfiguration is not an explicit argument - # to e.g. ecs.run_task, it's just passed as a keyword argument) - return self.module.botocore_at_least('1.7.44') - - def ecs_api_handles_network_configuration_assignIp(self): - # There doesn't seem to be a nice way to inspect botocore to look - # for attributes (and networkConfiguration is not an explicit argument - # to e.g. ecs.run_task, it's just passed as a keyword argument) - return self.module.botocore_at_least('1.8.4') - def main(): argument_spec = dict( @@ -404,18 +379,7 @@ def main(): service_mgr = EcsExecManager(module) - if module.params['network_configuration']: - if 'assignPublicIp' in module.params['network_configuration'] and not service_mgr.ecs_api_handles_network_configuration_assignIp(): - module.fail_json(msg='botocore needs to be version 1.8.4 or higher to use assign_public_ip in network_configuration') - elif not service_mgr.ecs_api_handles_network_configuration(): - module.fail_json(msg='botocore needs to be version 1.7.44 or higher to use network configuration') - - if module.params['launch_type'] and not service_mgr.ecs_api_handles_launch_type(): - module.fail_json(msg='botocore needs to be version 1.8.4 or higher to use launch type') - if module.params['tags']: - if not service_mgr.ecs_api_handles_tags(): - module.fail_json(msg=missing_required_lib("botocore >= 1.12.46", reason="to use tags")) if not service_mgr.ecs_task_long_format_enabled(): module.fail_json(msg="Cannot set task tags: long format task arns are required to set tags") diff --git a/plugins/modules/ecs_taskdefinition.py b/plugins/modules/ecs_taskdefinition.py index 6696e92acb3..8c8a2960ac2 100644 --- a/plugins/modules/ecs_taskdefinition.py +++ b/plugins/modules/ecs_taskdefinition.py @@ -770,14 +770,6 @@ def main(): task_mgr = EcsTaskManager(module) results = dict(changed=False) - if module.params['launch_type']: - if not module.botocore_at_least('1.8.4'): - module.fail_json(msg='botocore needs to be version 1.8.4 or higher to use launch_type') - - if module.params['execution_role_arn']: - if not module.botocore_at_least('1.10.44'): - module.fail_json(msg='botocore needs to be version 1.10.44 or higher to use execution_role_arn') - if module.params['state'] == 'present': if 'containers' not in module.params or not module.params['containers']: module.fail_json(msg="To use task definitions, a list of containers must be specified") diff --git a/plugins/modules/efs.py b/plugins/modules/efs.py index 49fbd73c9a3..0cf4f88c1d7 100644 --- a/plugins/modules/efs.py +++ b/plugins/modules/efs.py @@ -79,13 +79,11 @@ throughput_mode: description: - The throughput_mode for the file system to be created. - - Requires botocore >= 1.10.57 choices: ['bursting', 'provisioned'] type: str provisioned_throughput_in_mibps: description: - If the throughput_mode is provisioned, select the amount of throughput to provisioned in Mibps. - - Requires botocore >= 1.10.57 type: float wait: description: @@ -370,12 +368,6 @@ def get_mount_targets_in_state(self, file_system_id, states=None): return list(targets) - def supports_provisioned_mode(self): - """ - Ensure boto3 includes provisioned throughput mode feature - """ - return hasattr(self.connection, 'update_file_system') - def get_throughput_mode(self, **kwargs): """ Returns throughput mode for selected EFS instance @@ -413,15 +405,9 @@ def create_file_system(self, name, performance_mode, encrypt, kms_key_id, throug if kms_key_id is not None: params['KmsKeyId'] = kms_key_id if throughput_mode: - if self.supports_provisioned_mode(): - params['ThroughputMode'] = throughput_mode - else: - self.module.fail_json(msg="throughput_mode parameter requires botocore >= 1.10.57") + params['ThroughputMode'] = throughput_mode if provisioned_throughput_in_mibps: - if self.supports_provisioned_mode(): - params['ProvisionedThroughputInMibps'] = provisioned_throughput_in_mibps - else: - self.module.fail_json(msg="provisioned_throughput_in_mibps parameter requires botocore >= 1.10.57") + params['ProvisionedThroughputInMibps'] = provisioned_throughput_in_mibps if state in [self.STATE_DELETING, self.STATE_DELETED]: wait_for( @@ -731,8 +717,7 @@ def main(): module.fail_json(msg='Name parameter is required for create') changed = connection.create_file_system(name, performance_mode, encrypt, kms_key_id, throughput_mode, provisioned_throughput_in_mibps) - if connection.supports_provisioned_mode(): - changed = connection.update_file_system(name, throughput_mode, provisioned_throughput_in_mibps) or changed + changed = connection.update_file_system(name, throughput_mode, provisioned_throughput_in_mibps) or changed changed = connection.converge_file_system(name=name, tags=tags, purge_tags=purge_tags, targets=targets, throughput_mode=throughput_mode, provisioned_throughput_in_mibps=provisioned_throughput_in_mibps) or changed result = first_or_default(connection.get_file_systems(CreationToken=name)) diff --git a/plugins/modules/efs_info.py b/plugins/modules/efs_info.py index 2384af97ee1..9a6ce1786fc 100644 --- a/plugins/modules/efs_info.py +++ b/plugins/modules/efs_info.py @@ -148,12 +148,12 @@ sample: "generalPurpose" throughput_mode: description: mode of throughput for the file system - returned: when botocore >= 1.10.57 + returned: always type: str sample: "bursting" provisioned_throughput_in_mibps: description: throughput provisioned in Mibps - returned: when botocore >= 1.10.57 and throughput_mode is set to "provisioned" + returned: when throughput_mode is set to "provisioned" type: float sample: 15.0 tags: diff --git a/plugins/modules/elb_target_group.py b/plugins/modules/elb_target_group.py index 7bb105b6d55..722d7afa013 100644 --- a/plugins/modules/elb_target_group.py +++ b/plugins/modules/elb_target_group.py @@ -454,12 +454,6 @@ def wait_for_status(connection, module, target_group_arn, targets, status): return status_achieved, result -def fail_if_ip_target_type_not_supported(module): - if not module.botocore_at_least('1.7.2'): - module.fail_json(msg="target_type ip requires botocore version 1.7.2 or later. Version %s is installed" % - botocore.__version__) - - def create_or_update_target_group(connection, module): changed = False @@ -519,10 +513,6 @@ def create_or_update_target_group(connection, module): params['Matcher'] = {} params['Matcher']['HttpCode'] = module.params.get("successful_response_codes") - # Get target type - if target_type == 'ip': - fail_if_ip_target_type_not_supported(module) - # Get target group tg = get_target_group(connection, module) diff --git a/plugins/modules/iam_role.py b/plugins/modules/iam_role.py index 45551cdf188..e696d9d7417 100644 --- a/plugins/modules/iam_role.py +++ b/plugins/modules/iam_role.py @@ -34,7 +34,6 @@ - Boundaries cannot be set on Instance Profiles, as such if this option is specified then I(create_instance_profile) must be C(false). - This is intended for roles/users that have permissions to create new IAM objects. - For more information on boundaries, see U(https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html). - - Requires botocore 1.10.57 or above. aliases: [boundary_policy_arn] type: str assume_role_policy_document: @@ -82,7 +81,6 @@ tags: description: - Tag dict to apply to the queue. - - Requires botocore 1.12.46 or above. type: dict purge_tags: description: @@ -566,8 +564,6 @@ def get_attached_policy_list(connection, module, name): def get_role_tags(connection, module): role_name = module.params.get('name') - if not hasattr(connection, 'list_role_tags'): - return {} try: return boto3_tag_list_to_ansible_dict(connection.list_role_tags(RoleName=role_name, aws_retry=True)['Tags']) except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: @@ -633,12 +629,6 @@ def main(): module.fail_json(msg="When using a boundary policy, `create_instance_profile` must be set to `false`.") if not module.params.get('boundary').startswith('arn:aws:iam'): module.fail_json(msg="Boundary policy must be an ARN") - if module.params.get('tags') is not None and not module.botocore_at_least('1.12.46'): - module.fail_json(msg="When managing tags botocore must be at least v1.12.46. " - "Current versions: boto3-{boto3_version} botocore-{botocore_version}".format(**module._gather_versions())) - if module.params.get('boundary') is not None and not module.botocore_at_least('1.10.57'): - module.fail_json(msg="When using a boundary policy, botocore must be at least v1.10.57. " - "Current versions: boto3-{boto3_version} botocore-{botocore_version}".format(**module._gather_versions())) if module.params.get('max_session_duration'): max_session_duration = module.params.get('max_session_duration') if max_session_duration < 3600 or max_session_duration > 43200: diff --git a/plugins/modules/lambda.py b/plugins/modules/lambda.py index 0a25214ca37..1605d6497db 100644 --- a/plugins/modules/lambda.py +++ b/plugins/modules/lambda.py @@ -105,7 +105,7 @@ type: str tags: description: - - tag dict to apply to the function (requires botocore 1.5.40 or above). + - Tag dict to apply to the function. type: dict author: - 'Steyn Huizinga (@steynovich)' @@ -384,10 +384,6 @@ def main(): except (ClientError, BotoCoreError) as e: module.fail_json_aws(e, msg="Trying to connect to AWS") - if tags is not None: - if not hasattr(client, "list_tags"): - module.fail_json(msg="Using tags requires botocore 1.5.40 or above") - if state == 'present': if re.match(r'^arn:aws(-([a-z\-]+))?:iam', role): role_arn = role diff --git a/plugins/modules/rds_instance.py b/plugins/modules/rds_instance.py index ea6da26f0b6..6e894005ab9 100644 --- a/plugins/modules/rds_instance.py +++ b/plugins/modules/rds_instance.py @@ -1198,9 +1198,6 @@ def main(): supports_check_mode=True ) - if not module.boto3_at_least('1.5.0'): - module.fail_json(msg="rds_instance requires boto3 > 1.5.0") - # Sanitize instance identifiers module.params['db_instance_identifier'] = module.params['db_instance_identifier'].lower() if module.params['new_db_instance_identifier']: diff --git a/plugins/modules/sqs_queue.py b/plugins/modules/sqs_queue.py index 0de9d205b35..45a8ccfc079 100644 --- a/plugins/modules/sqs_queue.py +++ b/plugins/modules/sqs_queue.py @@ -86,7 +86,7 @@ - Defaults to C(false). tags: description: - - Tag dict to apply to the queue (requires botocore 1.5.40 or above). + - Tag dict to apply to the queue. - To remove all tags set I(tags={}) and I(purge_tags=true). type: dict purge_tags: From af7fa0a853f5eab9d80773fad50bd9ebcd61e809 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Fri, 6 Aug 2021 10:45:49 +0200 Subject: [PATCH 2/6] Move MSK dependencies to botocore version rather than boto3 version The relevant method definitions live (as data files) in botocore. boto3 -> botocore version mapping is unreliable. --- plugins/modules/aws_msk_cluster.py | 13 ++++++------- plugins/modules/aws_msk_config.py | 18 +++++------------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/plugins/modules/aws_msk_cluster.py b/plugins/modules/aws_msk_cluster.py index 7f85c00a59b..41f2dd62e44 100644 --- a/plugins/modules/aws_msk_cluster.py +++ b/plugins/modules/aws_msk_cluster.py @@ -12,9 +12,6 @@ module: aws_msk_cluster short_description: Manage Amazon MSK clusters. version_added: "2.0.0" -requirements: - - botocore >= 1.17.42 - - boto3 >= 1.17.9 description: - Create, delete and modify Amazon MSK (Managed Streaming for Apache Kafka) clusters. author: @@ -34,6 +31,7 @@ - The version of Apache Kafka. - This version should exist in given configuration. - This parameter is required when I(state=present). + - Update operation requires botocore version >= 1.16.19. type: str configuration_arn: description: @@ -52,7 +50,7 @@ instance_type: description: - The type of Amazon EC2 instances to use for Kafka brokers. - - Update operation requires boto3 version >= 1.16.58 + - Update operation requires botocore version >= 1.19.58. choices: - kafka.t3.small - kafka.m5.large @@ -522,7 +520,7 @@ def create_or_update_cluster(client, module): } }, "broker_type": { - "boto3_version": "1.16.58", + "botocore_version": "1.19.58", "current_value": cluster["BrokerNodeGroupInfo"]["InstanceType"], "target_value": module.params.get("instance_type"), "update_params": { @@ -546,6 +544,7 @@ def create_or_update_cluster(client, module): } }, "cluster_kafka_version": { + "botocore_version": "1.16.19", "current_value": cluster["CurrentBrokerSoftwareInfo"]["KafkaVersion"], "target_value": module.params.get("version"), "update_params": { @@ -578,8 +577,8 @@ def create_or_update_cluster(client, module): for method, options in msk_cluster_changes.items(): - if 'boto3_version' in options: - if not module.boto3_at_least(options["boto3_version"]): + if 'botocore_version' in options: + if not module.botocore_at_least(options["botocore_version"]): continue try: diff --git a/plugins/modules/aws_msk_config.py b/plugins/modules/aws_msk_config.py index c02769152a5..2d0d6738b3f 100644 --- a/plugins/modules/aws_msk_config.py +++ b/plugins/modules/aws_msk_config.py @@ -13,8 +13,8 @@ short_description: Manage Amazon MSK cluster configurations. version_added: "2.0.0" requirements: - - botocore >= 1.17.42 - - boto3 >= 1.17.9 + - botocore >= 1.17.48 + - boto3 description: - Create, delete and modify Amazon MSK (Managed Streaming for Apache Kafka) cluster configurations. author: @@ -104,9 +104,6 @@ ) -BOTOCORE_MIN_VERSION = "1.17.42" - - def dict_to_prop(d): """convert dictionary to multi-line properties""" if len(d) == 0: @@ -138,8 +135,6 @@ def get_configurations_with_backoff(client): def find_active_config(client, module): """ looking for configuration by name - status is not returned for list_configurations in botocore 1.17.42 - delete_configuration method was added in botocore 1.17.48 """ name = module.params["name"] @@ -284,12 +279,9 @@ def main(): module = AnsibleAWSModule(argument_spec=module_args, supports_check_mode=True) - if not module.botocore_at_least(BOTOCORE_MIN_VERSION): - module.fail_json( - msg="aws_msk_config module requires botocore >= {0}".format( - BOTOCORE_MIN_VERSION - ) - ) + # Support for update_configuration and delete_configuration added in 1.17.48 + if not module.botocore_at_least("1.17.48"): + module.fail_json(msg="aws_msk_config module requires botocore >= 1.17.48") client = module.client("kafka", retry_decorator=AWSRetry.jittered_backoff()) From 3b47cf2c9bdc20a66f6a70e21cb48dc5a3f90433 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Fri, 6 Aug 2021 10:51:33 +0200 Subject: [PATCH 3/6] sync test-requirements from amazon.aws --- test-requirements.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test-requirements.txt b/test-requirements.txt index fdb812e3c54..3d217284154 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,3 +4,7 @@ mock pytest-xdist # We should avoid these two modules with py3 pytest-mock +# Needed for ansible.netcommon.ipaddr in tests +netaddr +# Sometimes needed where we don't have features we need in modules +awscli From 817dab108d670077e2c5d80ed1f8b9f81ab2815e Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Fri, 6 Aug 2021 11:00:29 +0200 Subject: [PATCH 4/6] Remove integration tests for unsupported versions of boto3/botocore --- .../tasks/botocore_lt_1.10.1.yml | 12 -- .../tasks/botocore_lt_1.12.38.yml | 13 --- .../targets/aws_eks_cluster/tasks/main.yml | 66 ----------- .../tasks/graceful_failure.yml | 21 ---- .../ec2_launch_template/tasks/main.yml | 32 ------ .../targets/ec2_metric_alarm/tasks/main.yml | 6 - .../targets/ecs_cluster/tasks/main.yml | 53 --------- .../tasks/network_assign_public_ip_fail.yml | 106 ----------------- .../network_force_new_deployment_fail.yml | 108 ------------------ .../elb_application_lb/tasks/full_test.yml | 5 - .../targets/elb_application_lb/tasks/main.yml | 28 ----- .../tasks/test_multiple_actions_fail.yml | 50 -------- .../elb_application_lb_info/tasks/main.yml | 29 ----- 13 files changed, 529 deletions(-) delete mode 100644 tests/integration/targets/aws_eks_cluster/tasks/botocore_lt_1.10.1.yml delete mode 100644 tests/integration/targets/aws_eks_cluster/tasks/botocore_lt_1.12.38.yml delete mode 100644 tests/integration/targets/ec2_launch_template/tasks/graceful_failure.yml delete mode 100644 tests/integration/targets/ecs_cluster/tasks/network_assign_public_ip_fail.yml delete mode 100644 tests/integration/targets/ecs_cluster/tasks/network_force_new_deployment_fail.yml delete mode 100644 tests/integration/targets/elb_application_lb/tasks/test_multiple_actions_fail.yml diff --git a/tests/integration/targets/aws_eks_cluster/tasks/botocore_lt_1.10.1.yml b/tests/integration/targets/aws_eks_cluster/tasks/botocore_lt_1.10.1.yml deleted file mode 100644 index e4c4b31fe5e..00000000000 --- a/tests/integration/targets/aws_eks_cluster/tasks/botocore_lt_1.10.1.yml +++ /dev/null @@ -1,12 +0,0 @@ -- name: try and use aws_eks_cluster module - aws_eks_cluster: - state: absent - name: my_cluster - ignore_errors: yes - register: aws_eks_cluster - -- name: ensure that aws_eks fails with friendly error message - assert: - that: - - '"msg" in aws_eks_cluster' - - aws_eks_cluster is failed diff --git a/tests/integration/targets/aws_eks_cluster/tasks/botocore_lt_1.12.38.yml b/tests/integration/targets/aws_eks_cluster/tasks/botocore_lt_1.12.38.yml deleted file mode 100644 index 4feb7ab48fc..00000000000 --- a/tests/integration/targets/aws_eks_cluster/tasks/botocore_lt_1.12.38.yml +++ /dev/null @@ -1,13 +0,0 @@ -- name: try using aws_eks_cluster wait with state=absent - aws_eks_cluster: - state: absent - name: my_cluster - wait: yes - ignore_errors: yes - register: aws_eks_cluster - -- name: ensure that aws_eks fails with friendly error message - assert: - that: - - '"msg" in aws_eks_cluster' - - aws_eks_cluster is failed diff --git a/tests/integration/targets/aws_eks_cluster/tasks/main.yml b/tests/integration/targets/aws_eks_cluster/tasks/main.yml index 95fb241298e..61aa32cd19d 100644 --- a/tests/integration/targets/aws_eks_cluster/tasks/main.yml +++ b/tests/integration/targets/aws_eks_cluster/tasks/main.yml @@ -9,70 +9,4 @@ security_token: '{{ security_token | default(omit) }}' region: '{{ aws_region }}' block: - - - set_fact: - virtualenv: "{{ remote_tmp_dir }}/virtualenv" - virtualenv_command: "{{ ansible_python_interpreter }} -m virtualenv" - - - set_fact: - virtualenv_interpreter: "{{ virtualenv }}/bin/python" - - - pip: - name: virtualenv - - # Test graceful failure for missing kubernetes-validate - - - pip: - name: - - 'botocore<1.10.1' - - boto3 - - coverage<5 - virtualenv: "{{ virtualenv }}" - virtualenv_command: "{{ virtualenv_command }}" - virtualenv_site_packages: no - - - include_tasks: botocore_lt_1.10.1.yml - vars: - ansible_python_interpreter: "{{ virtualenv_interpreter }}" - - - file: - path: "{{ virtualenv }}" - state: absent - - # Test graceful failures when botocore<1.12.38 - - - pip: - name: - - 'botocore>1.10.1,<1.12.38' - - boto3 - - coverage<5 - virtualenv: "{{ virtualenv }}" - virtualenv_command: "{{ virtualenv_command }}" - virtualenv_site_packages: no - - - include_tasks: botocore_lt_1.12.38.yml - vars: - ansible_python_interpreter: "{{ virtualenv_interpreter }}" - - - file: - path: "{{ virtualenv }}" - state: absent - - # Test validate with kubernetes-validate - - - pip: - name: - - 'botocore>=1.10.1' - - boto3 - virtualenv: "{{ virtualenv }}" - virtualenv_command: "{{ virtualenv_command }}" - virtualenv_site_packages: no - - include_tasks: full_test.yml - vars: - ansible_python_interpreter: "{{ virtualenv_interpreter }}" - playbook_namespace: ansible-test-k8s-validate - - - file: - path: "{{ virtualenv }}" - state: absent diff --git a/tests/integration/targets/ec2_launch_template/tasks/graceful_failure.yml b/tests/integration/targets/ec2_launch_template/tasks/graceful_failure.yml deleted file mode 100644 index 208add29667..00000000000 --- a/tests/integration/targets/ec2_launch_template/tasks/graceful_failure.yml +++ /dev/null @@ -1,21 +0,0 @@ -- block: - - name: create c4.large template (failure expected) - ec2_launch_template: - state: present - name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-tpl" - instance_type: c4.large - register: ec2_lt - ignore_errors: yes - - - name: check that graceful error message is returned when creation with cpu_options and old botocore - assert: - that: - - ec2_lt is failed - - 'ec2_lt.msg == "ec2_launch_template requires boto3 >= 1.6.0"' - - always: - - name: delete the c4.large template just in case it was created - ec2_launch_template: - state: absent - name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-tpl" - ignore_errors: yes diff --git a/tests/integration/targets/ec2_launch_template/tasks/main.yml b/tests/integration/targets/ec2_launch_template/tasks/main.yml index 8aba8e918c0..813c0fdf211 100644 --- a/tests/integration/targets/ec2_launch_template/tasks/main.yml +++ b/tests/integration/targets/ec2_launch_template/tasks/main.yml @@ -6,32 +6,6 @@ security_token: "{{ security_token | default(omit) }}" region: "{{ aws_region }}" block: - - - set_fact: - virtualenv: "{{ remote_tmp_dir }}/virtualenv" - virtualenv_command: "{{ ansible_python_interpreter }} -m virtualenv" - - - set_fact: - virtualenv_interpreter: "{{ virtualenv }}/bin/python" - - - pip: - name: virtualenv - - - pip: - name: - - 'boto3<1.6.0' - - botocore - - boto - - coverage<5 - - cryptography - virtualenv: "{{ virtualenv }}" - virtualenv_command: "{{ virtualenv_command }}" - virtualenv_site_packages: no - - - include_tasks: graceful_failure.yml - vars: - ansible_python_interpreter: "{{ virtualenv_interpreter }}" - - name: Find AMI to use ec2_ami_info: owners: 'amazon' @@ -46,9 +20,3 @@ - include_tasks: versions.yml - include_tasks: instance-metadata.yml - include_tasks: network_interfaces.yml - - always: - - - file: - path: "{{ virtualenv }}" - state: absent diff --git a/tests/integration/targets/ec2_metric_alarm/tasks/main.yml b/tests/integration/targets/ec2_metric_alarm/tasks/main.yml index e2980616ca3..1241655a9b9 100644 --- a/tests/integration/targets/ec2_metric_alarm/tasks/main.yml +++ b/tests/integration/targets/ec2_metric_alarm/tasks/main.yml @@ -12,12 +12,6 @@ - set_fact: alarm_full_name: "{{ alarm_prefix }}-{{ resource_prefix }}-cpu-low" - # until there's a module to get info about alarms, awscli is needed - - name: install awscli - pip: - state: present - name: awscli - - name: set up environment for testing. include_tasks: env_setup.yml diff --git a/tests/integration/targets/ecs_cluster/tasks/main.yml b/tests/integration/targets/ecs_cluster/tasks/main.yml index bd727cca3a4..fdcdd16a669 100644 --- a/tests/integration/targets/ecs_cluster/tasks/main.yml +++ b/tests/integration/targets/ecs_cluster/tasks/main.yml @@ -10,58 +10,5 @@ region: '{{ aws_region }}' block: - - set_fact: - virtualenv: "{{ remote_tmp_dir }}/virtualenv" - virtualenv_command: "{{ ansible_python_interpreter }} -m virtualenv" - - - set_fact: - virtualenv_interpreter: "{{ virtualenv }}/bin/python" - - - pip: - name: virtualenv - - # Test graceful failures when botocore<1.8.4 - - - pip: - name: - - 'botocore<1.8.4' - - boto3 - - coverage<5 - virtualenv: "{{ virtualenv }}" - virtualenv_command: "{{ virtualenv_command }}" - virtualenv_site_packages: no - - - include_tasks: network_assign_public_ip_fail.yml - vars: - ansible_python_interpreter: "{{ virtualenv_interpreter }}" - - - include_tasks: network_force_new_deployment_fail.yml - vars: - ansible_python_interpreter: "{{ virtualenv_interpreter }}" - - - file: - path: "{{ virtualenv }}" - state: absent - - # Test graceful failures when botocore<1.12.38 - - - pip: - name: - - 'botocore>=1.12.60' - - 'boto3>=1.16.57' - - coverage<5 - virtualenv: "{{ virtualenv }}" - virtualenv_command: "{{ virtualenv_command }}" - virtualenv_site_packages: no - - include_tasks: network_force_new_deployment.yml - vars: - ansible_python_interpreter: "{{ virtualenv_interpreter }}" - - include_tasks: full_test.yml - vars: - ansible_python_interpreter: "{{ virtualenv_interpreter }}" - - - file: - path: "{{ virtualenv }}" - state: absent diff --git a/tests/integration/targets/ecs_cluster/tasks/network_assign_public_ip_fail.yml b/tests/integration/targets/ecs_cluster/tasks/network_assign_public_ip_fail.yml deleted file mode 100644 index 46999fe0f4c..00000000000 --- a/tests/integration/targets/ecs_cluster/tasks/network_assign_public_ip_fail.yml +++ /dev/null @@ -1,106 +0,0 @@ ---- -- block: - - name: create ecs cluster - ecs_cluster: - name: "{{ resource_prefix }}" - state: present - - - name: create ecs_taskdefinition with bridged network - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}" - state: present - network_mode: bridge - register: ecs_taskdefinition_creation - - - name: create ecs_taskdefinition with awsvpc network - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}-vpc" - state: present - network_mode: awsvpc - register: ecs_taskdefinition_creation_vpc - - - name: ecs_taskdefinition works fine even when older botocore is used - assert: - that: - - ecs_taskdefinition_creation_vpc.changed - - - name: create ecs_service using awsvpc network_configuration - ecs_service: - name: "{{ resource_prefix }}-vpc" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}-vpc" - desired_count: 1 - network_configuration: - subnets: - - subnet-abcd1234 - security_groups: - - sg-abcd1234 - assign_public_ip: true - state: present - register: ecs_service_creation_vpc - ignore_errors: yes - - - name: check that graceful failure message is returned from ecs_service - assert: - that: - - ecs_service_creation_vpc.failed - - 'ecs_service_creation_vpc.msg == "botocore needs to be version 1.8.4 or higher to use assign_public_ip in network_configuration"' - - always: - - name: scale down ecs service - ecs_service: - name: "{{ resource_prefix }}" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}" - desired_count: 0 - state: present - ignore_errors: yes - - - name: pause to wait for scale down - pause: - seconds: 30 - - - name: remove ecs service - ecs_service: - name: "{{ resource_prefix }}" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}" - desired_count: 1 - state: absent - ignore_errors: yes - - - name: remove ecs task definition - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}" - revision: "{{ ecs_taskdefinition_creation.taskdefinition.revision }}" - state: absent - ignore_errors: yes - - - name: remove ecs task definition vpc - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}-vpc" - revision: "{{ ecs_taskdefinition_creation_vpc.taskdefinition.revision }}" - state: absent - ignore_errors: yes - - - name: remove ecs cluster - ecs_cluster: - name: "{{ resource_prefix }}" - state: absent - ignore_errors: yes diff --git a/tests/integration/targets/ecs_cluster/tasks/network_force_new_deployment_fail.yml b/tests/integration/targets/ecs_cluster/tasks/network_force_new_deployment_fail.yml deleted file mode 100644 index f65c20850c5..00000000000 --- a/tests/integration/targets/ecs_cluster/tasks/network_force_new_deployment_fail.yml +++ /dev/null @@ -1,108 +0,0 @@ ---- -- block: - - name: create ecs cluster - ecs_cluster: - name: "{{ resource_prefix }}" - state: present - - - name: create ecs_taskdefinition - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}" - state: present - register: ecs_taskdefinition_creation - - # even after deleting the cluster and recreating with a different name - # the previous service can prevent the current service from starting - # while it's in a draining state. Check the service info and sleep - # if the service does not report as inactive. - - - name: check if service is still running from a previous task - ecs_service_info: - service: "{{ resource_prefix }}" - cluster: "{{ resource_prefix }}" - details: yes - register: ecs_service_info_results - - name: delay if the service was not inactive - debug: var=ecs_service_info_results - - - name: delay if the service was not inactive - pause: - seconds: 30 - when: - - ecs_service_info_results.services|length >0 - - ecs_service_info_results.services[0]['status'] != 'INACTIVE' - - - name: create ecs_service - ecs_service: - name: "{{ resource_prefix }}" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}" - desired_count: 1 - state: present - register: ecs_service_creation - - - name: ecs_service works fine even when older botocore is used - assert: - that: - - ecs_service_creation.changed - - - name: create ecs_service using force_new_deployment - ecs_service: - name: "{{ resource_prefix }}" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}" - desired_count: 1 - force_new_deployment: true - state: present - register: ecs_service_creation_force_new_deploy - ignore_errors: yes - - - name: check that graceful failure message is returned from ecs_service - assert: - that: - - ecs_service_creation_force_new_deploy.failed - - 'ecs_service_creation_force_new_deploy.msg == "botocore needs to be version 1.8.4 or higher to use force_new_deployment"' - - always: - - name: scale down ecs service - ecs_service: - name: "{{ resource_prefix }}" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}" - desired_count: 0 - state: present - ignore_errors: yes - - - name: pause to wait for scale down - pause: - seconds: 30 - - - name: remove ecs service - ecs_service: - name: "{{ resource_prefix }}" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}" - desired_count: 1 - state: absent - ignore_errors: yes - - - name: remove ecs task definition - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}" - revision: "{{ ecs_taskdefinition_creation.taskdefinition.revision }}" - state: absent - ignore_errors: yes - - - name: remove ecs cluster - ecs_cluster: - name: "{{ resource_prefix }}" - state: absent - ignore_errors: yes diff --git a/tests/integration/targets/elb_application_lb/tasks/full_test.yml b/tests/integration/targets/elb_application_lb/tasks/full_test.yml index bf68f93aefa..e260d0f7f5c 100644 --- a/tests/integration/targets/elb_application_lb/tasks/full_test.yml +++ b/tests/integration/targets/elb_application_lb/tasks/full_test.yml @@ -91,11 +91,6 @@ state: present register: tg - # Run tests for graceful failure with an old version of botocore - - include_tasks: test_multiple_actions_fail.yml - vars: - ansible_python_interpreter: "{{ virtualenv_interpreter }}" - # Run main tests - include_tasks: test_alb_bad_listener_options.yml - include_tasks: test_alb_ip_address_type_options.yml diff --git a/tests/integration/targets/elb_application_lb/tasks/main.yml b/tests/integration/targets/elb_application_lb/tasks/main.yml index 5bf26c54fd5..90914288d88 100644 --- a/tests/integration/targets/elb_application_lb/tasks/main.yml +++ b/tests/integration/targets/elb_application_lb/tasks/main.yml @@ -9,32 +9,4 @@ region: '{{ aws_region }}' block: - # Prepare a virtual environment for multiple_actions_fail.yml - - set_fact: - virtualenv: "{{ remote_tmp_dir }}/virtualenv" - virtualenv_command: "{{ ansible_python_interpreter }} -m virtualenv" - - - set_fact: - virtualenv_interpreter: "{{ virtualenv }}/bin/python" - - - pip: - name: virtualenv - - - pip: - name: - - 'botocore<1.10.30' - - boto3 - - boto - - coverage<5 - - cryptography - virtualenv: "{{ virtualenv }}" - virtualenv_command: "{{ virtualenv_command }}" - virtualenv_site_packages: no - - include_tasks: full_test.yml - - always: - - - file: - path: "{{ virtualenv }}" - state: absent diff --git a/tests/integration/targets/elb_application_lb/tasks/test_multiple_actions_fail.yml b/tests/integration/targets/elb_application_lb/tasks/test_multiple_actions_fail.yml deleted file mode 100644 index 2e0d0700825..00000000000 --- a/tests/integration/targets/elb_application_lb/tasks/test_multiple_actions_fail.yml +++ /dev/null @@ -1,50 +0,0 @@ -- block: - - - name: register dummy OIDC config - set_fact: - AuthenticateOidcActionConfig: - AuthorizationEndpoint: "https://www.example.com/auth" - ClientId: "eeeeeeeeeeeeeeeeeeeeeeeeee" - ClientSecret: "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" - Issuer: "https://www.example.com/issuer" - OnUnauthenticatedRequest: "authenticate" - Scope: "openid" - SessionCookieName: "AWSELBAuthSessionCookie" - SessionTimeout: 604800 - TokenEndpoint: "https://www.example.com/token" - UserInfoEndpoint: "https://www.example.com/userinfo" - - - name: create ALB with multiple DefaultActions - elb_application_lb: - name: "{{ alb_name }}" - subnets: "{{ alb_subnets }}" - security_groups: "{{ sec_group.group_id }}" - state: present - listeners: - - Protocol: HTTP - Port: 80 - DefaultActions: - - Type: forward - TargetGroupName: "{{ tg_name }}" - Order: 2 - - Type: authenticate-oidc - AuthenticateOidcConfig: "{{ AuthenticateOidcActionConfig }}" - Order: 1 - register: alb - ignore_errors: yes - - - name: check for a graceful failure message - assert: - that: - - alb.failed - - 'alb.msg == "installed version of botocore does not support multiple actions, please upgrade botocore to version 1.10.30 or higher"' - - always: - # Cleanup - - name: destroy ALB if created - elb_application_lb: - name: '{{ alb_name }}' - state: absent - wait: true - wait_timeout: 600 - ignore_errors: true diff --git a/tests/integration/targets/elb_application_lb_info/tasks/main.yml b/tests/integration/targets/elb_application_lb_info/tasks/main.yml index 4ec0660c237..5d9eb4fe73f 100644 --- a/tests/integration/targets/elb_application_lb_info/tasks/main.yml +++ b/tests/integration/targets/elb_application_lb_info/tasks/main.yml @@ -8,33 +8,4 @@ security_token: '{{ security_token | default(omit) }}' region: '{{ aws_region }}' block: - - # Prepare a virtual environment for multiple_actions_fail.yml - - set_fact: - virtualenv: "{{ remote_tmp_dir }}/virtualenv" - virtualenv_command: "{{ ansible_python_interpreter }} -m virtualenv" - - - set_fact: - virtualenv_interpreter: "{{ virtualenv }}/bin/python" - - - pip: - name: virtualenv - - - pip: - name: - - 'botocore<1.10.30' - - boto3 - - boto - - coverage<5 - - cryptography - virtualenv: "{{ virtualenv }}" - virtualenv_command: "{{ virtualenv_command }}" - virtualenv_site_packages: no - - include_tasks: full_test.yml - - always: - - - file: - path: "{{ virtualenv }}" - state: absent From fbe4d0caa1cfcbbb4a2bf4e8498668baa4a28f2c Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Fri, 6 Aug 2021 16:23:11 +0200 Subject: [PATCH 5/6] use require_botocore_at_least for aws_msk_config --- plugins/modules/aws_msk_config.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/modules/aws_msk_config.py b/plugins/modules/aws_msk_config.py index 2d0d6738b3f..6258ae916f6 100644 --- a/plugins/modules/aws_msk_config.py +++ b/plugins/modules/aws_msk_config.py @@ -280,8 +280,7 @@ def main(): module = AnsibleAWSModule(argument_spec=module_args, supports_check_mode=True) # Support for update_configuration and delete_configuration added in 1.17.48 - if not module.botocore_at_least("1.17.48"): - module.fail_json(msg="aws_msk_config module requires botocore >= 1.17.48") + module.require_botocore_at_least('1.17.48') client = module.client("kafka", retry_decorator=AWSRetry.jittered_backoff()) From 17e85772ef4dda92aa003364c6201b85dd475dba Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Tue, 10 Aug 2021 10:01:02 +0200 Subject: [PATCH 6/6] Remove integration tests testing for old (unsupported) versions of botocore --- .../playbooks/full_test.yml | 6 - .../targets/cloudformation_stack_set/runme.sh | 8 - .../ecs_cluster/tasks/network_fail.yml | 194 ------------------ .../targets/efs/playbooks/full_test.yml | 9 - .../targets/efs/playbooks/version_fail.yml | 32 --- tests/integration/targets/efs/runme.sh | 15 -- .../{playbooks/roles/efs => }/tasks/main.yml | 8 +- .../targets/elb_target/defaults/main.yml | 15 ++ .../files/ansible_lambda_target.py | 0 .../files/assume-role.json | 0 .../elb_target/playbooks/full_test.yml | 7 - .../roles/elb_lambda_target/defaults/main.yml | 5 - .../roles/elb_target/defaults/main.yml | 10 - .../elb_target/playbooks/version_fail.yml | 41 ---- tests/integration/targets/elb_target/runme.sh | 13 -- .../tasks/main.yml => tasks/ec2_target.yml} | 13 +- .../main.yml => tasks/lambda_target.yml} | 22 +- .../targets/elb_target/tasks/main.yml | 13 ++ 18 files changed, 48 insertions(+), 363 deletions(-) delete mode 100644 tests/integration/targets/cloudformation_stack_set/playbooks/full_test.yml delete mode 100755 tests/integration/targets/cloudformation_stack_set/runme.sh delete mode 100644 tests/integration/targets/ecs_cluster/tasks/network_fail.yml delete mode 100644 tests/integration/targets/efs/playbooks/full_test.yml delete mode 100644 tests/integration/targets/efs/playbooks/version_fail.yml delete mode 100755 tests/integration/targets/efs/runme.sh rename tests/integration/targets/efs/{playbooks/roles/efs => }/tasks/main.yml (99%) create mode 100644 tests/integration/targets/elb_target/defaults/main.yml rename tests/integration/targets/elb_target/{playbooks/roles/elb_lambda_target => }/files/ansible_lambda_target.py (100%) rename tests/integration/targets/elb_target/{playbooks/roles/elb_lambda_target => }/files/assume-role.json (100%) delete mode 100644 tests/integration/targets/elb_target/playbooks/full_test.yml delete mode 100644 tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/defaults/main.yml delete mode 100644 tests/integration/targets/elb_target/playbooks/roles/elb_target/defaults/main.yml delete mode 100644 tests/integration/targets/elb_target/playbooks/version_fail.yml delete mode 100755 tests/integration/targets/elb_target/runme.sh rename tests/integration/targets/elb_target/{playbooks/roles/elb_target/tasks/main.yml => tasks/ec2_target.yml} (97%) rename tests/integration/targets/elb_target/{playbooks/roles/elb_lambda_target/tasks/main.yml => tasks/lambda_target.yml} (92%) create mode 100644 tests/integration/targets/elb_target/tasks/main.yml diff --git a/tests/integration/targets/cloudformation_stack_set/playbooks/full_test.yml b/tests/integration/targets/cloudformation_stack_set/playbooks/full_test.yml deleted file mode 100644 index 257e1e48a51..00000000000 --- a/tests/integration/targets/cloudformation_stack_set/playbooks/full_test.yml +++ /dev/null @@ -1,6 +0,0 @@ -- hosts: localhost - connection: local - environment: "{{ ansible_test.environment }}" - - roles: - - ../../cloudformation_stack_set diff --git a/tests/integration/targets/cloudformation_stack_set/runme.sh b/tests/integration/targets/cloudformation_stack_set/runme.sh deleted file mode 100755 index d499c679b26..00000000000 --- a/tests/integration/targets/cloudformation_stack_set/runme.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -set -eux - -# Run full test suite -source virtualenv.sh -pip install 'botocore>1.10.26' boto3 -ansible-playbook -i ../../inventory -v playbooks/full_test.yml "$@" diff --git a/tests/integration/targets/ecs_cluster/tasks/network_fail.yml b/tests/integration/targets/ecs_cluster/tasks/network_fail.yml deleted file mode 100644 index d21eba22a0b..00000000000 --- a/tests/integration/targets/ecs_cluster/tasks/network_fail.yml +++ /dev/null @@ -1,194 +0,0 @@ ---- -- block: - - name: create ecs cluster - ecs_cluster: - name: "{{ resource_prefix }}" - state: present - - - name: create ecs_taskdefinition with bridged network - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}" - state: present - network_mode: bridge - register: ecs_taskdefinition_creation - - - name: create ecs_taskdefinition with awsvpc network - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}-vpc" - state: present - network_mode: awsvpc - register: ecs_taskdefinition_creation_vpc - - - name: create ecs_taskdefinition and execution_role_arn (expected to fail) - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}-vpc" - execution_role_arn: not_a_real_arn - state: present - network_mode: awsvpc - ignore_errors: yes - register: ecs_taskdefinition_arn - - - name: check that graceful failure message is returned from ecs_taskdefinition_arn - assert: - that: - - ecs_taskdefinition_arn.failed - - 'ecs_taskdefinition_arn.msg == "botocore needs to be version 1.10.44 or higher to use execution_role_arn"' - - - name: ecs_taskdefinition works fine even when older botocore is used - assert: - that: - - ecs_taskdefinition_creation_vpc.changed - - - name: create ecs_service using bridged network - ecs_service: - name: "{{ resource_prefix }}" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}" - desired_count: 1 - state: present - register: ecs_service_creation - - - name: create ecs_service using awsvpc network_configuration - ecs_service: - name: "{{ resource_prefix }}-vpc" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}-vpc" - desired_count: 1 - network_configuration: - subnets: - - subnet-abcd1234 - security_groups: - - sg-abcd1234 - state: present - register: ecs_service_creation_vpc - ignore_errors: yes - - - name: check that graceful failure message is returned from ecs_service - assert: - that: - - ecs_service_creation_vpc.failed - - 'ecs_service_creation_vpc.msg == "botocore needs to be version 1.7.44 or higher to use network configuration"' - - - name: create ecs_service using awsvpc network_configuration and launch_type - ecs_service: - name: "{{ resource_prefix }}-vpc" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}-vpc" - desired_count: 1 - network_configuration: - subnets: - - subnet-abcd1234 - security_groups: - - sg-abcd1234 - launch_type: FARGATE - state: present - register: ecs_service_creation_vpc_launchtype - ignore_errors: yes - - - name: check that graceful failure message is returned from ecs_service - assert: - that: - - ecs_service_creation_vpc_launchtype.failed - - 'ecs_service_creation_vpc_launchtype.msg == "botocore needs to be version 1.7.44 or higher to use network configuration"' - - - name: create ecs_service with launchtype and missing network_configuration - ecs_service: - name: "{{ resource_prefix }}-vpc" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}-vpc" - desired_count: 1 - launch_type: FARGATE - state: present - register: ecs_service_creation_vpc_launchtype_nonet - ignore_errors: yes - - - name: check that graceful failure message is returned from ecs_service - assert: - that: - - ecs_service_creation_vpc_launchtype_nonet.failed - - 'ecs_service_creation_vpc_launchtype_nonet.msg == "launch_type is FARGATE but all of the following are missing: network_configuration"' - - - name: create ecs_task using awsvpc network_configuration - ecs_task: - cluster: "{{ resource_prefix }}-vpc" - task_definition: "{{ resource_prefix }}" - operation: run - count: 1 - started_by: me - network_configuration: - subnets: - - subnet-abcd1234 - security_groups: - - sg-abcd1234 - register: ecs_task_creation_vpc - ignore_errors: yes - - - name: check that graceful failure message is returned from ecs_task - assert: - that: - - ecs_task_creation_vpc.failed - - 'ecs_task_creation_vpc.msg == "botocore needs to be version 1.7.44 or higher to use network configuration"' - - - always: - - name: scale down ecs service - ecs_service: - name: "{{ resource_prefix }}" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}" - desired_count: 0 - state: present - ignore_errors: yes - - - name: pause to wait for scale down - pause: - seconds: 30 - - - name: remove ecs service - ecs_service: - name: "{{ resource_prefix }}" - cluster: "{{ resource_prefix }}" - task_definition: "{{ resource_prefix }}" - desired_count: 1 - state: absent - ignore_errors: yes - - - name: remove ecs task definition - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}" - revision: "{{ ecs_taskdefinition_creation.taskdefinition.revision }}" - state: absent - ignore_errors: yes - - - name: remove ecs task definition vpc - ecs_taskdefinition: - containers: - - name: my_container - image: ubuntu - memory: 128 - family: "{{ resource_prefix }}-vpc" - revision: "{{ ecs_taskdefinition_creation_vpc.taskdefinition.revision }}" - state: absent - ignore_errors: yes - - - name: remove ecs cluster - ecs_cluster: - name: "{{ resource_prefix }}" - state: absent - ignore_errors: yes diff --git a/tests/integration/targets/efs/playbooks/full_test.yml b/tests/integration/targets/efs/playbooks/full_test.yml deleted file mode 100644 index e15e5aa4e90..00000000000 --- a/tests/integration/targets/efs/playbooks/full_test.yml +++ /dev/null @@ -1,9 +0,0 @@ -- hosts: localhost - connection: local -# environment: "{{ ansible_test.environment }}" - - vars: - resource_prefix: 'ansible-testing' - - roles: - - efs diff --git a/tests/integration/targets/efs/playbooks/version_fail.yml b/tests/integration/targets/efs/playbooks/version_fail.yml deleted file mode 100644 index 6d73b75867e..00000000000 --- a/tests/integration/targets/efs/playbooks/version_fail.yml +++ /dev/null @@ -1,32 +0,0 @@ -- hosts: localhost - connection: local - environment: "{{ ansible_test.environment }}" - vars: - resource_prefix: 'ansible-testing' - - tasks: - - name: 'efs graceful failure tests' - collections: - - amazon.aws - module_defaults: - group/aws: - aws_access_key: '{{ aws_access_key }}' - aws_secret_key: '{{ aws_secret_key }}' - security_token: '{{ security_token | default(omit) }}' - region: '{{ aws_region }}' - block: - - - name: create efs with provisioned_throughput options (fails gracefully) - efs: - state: present - name: "{{ resource_prefix }}-efs" - throughput_mode: 'provisioned' - provisioned_throughput_in_mibps: 8.0 - register: efs_provisioned_throughput_creation - ignore_errors: yes - - - name: check that graceful error message is returned when creation with throughput_mode and old botocore - assert: - that: - - efs_provisioned_throughput_creation.failed - - 'efs_provisioned_throughput_creation.msg == "throughput_mode parameter requires botocore >= 1.10.57"' diff --git a/tests/integration/targets/efs/runme.sh b/tests/integration/targets/efs/runme.sh deleted file mode 100755 index e4f214b8e85..00000000000 --- a/tests/integration/targets/efs/runme.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -set -eux - -export ANSIBLE_ROLES_PATH=../ - -# Test graceful failure for older versions of botocore -source virtualenv.sh -pip install 'botocore<1.10.57' boto3 -ansible-playbook -i ../../inventory -v playbooks/version_fail.yml "$@" - -# Run full test suite -source virtualenv.sh -pip install 'botocore>=1.10.57' boto3 -ansible-playbook -i ../../inventory -v playbooks/full_test.yml "$@" diff --git a/tests/integration/targets/efs/playbooks/roles/efs/tasks/main.yml b/tests/integration/targets/efs/tasks/main.yml similarity index 99% rename from tests/integration/targets/efs/playbooks/roles/efs/tasks/main.yml rename to tests/integration/targets/efs/tasks/main.yml index 094ac782628..93071a2becd 100644 --- a/tests/integration/targets/efs/playbooks/roles/efs/tasks/main.yml +++ b/tests/integration/targets/efs/tasks/main.yml @@ -168,8 +168,8 @@ provisioned_throughput_in_mibps: 5.0 register: efs_result - - assert: - that: + - assert: + that: - efs_result is changed # ============================================================ @@ -186,9 +186,9 @@ throughput_mode: 'provisioned' provisioned_throughput_in_mibps: 5.0 register: efs_result - + - assert: - that: + that: - efs_result is not changed - efs_result.efs["throughput_mode"] == "provisioned" - efs_result.efs["provisioned_throughput_in_mibps"] == 5.0 diff --git a/tests/integration/targets/elb_target/defaults/main.yml b/tests/integration/targets/elb_target/defaults/main.yml new file mode 100644 index 00000000000..14068f1e5c0 --- /dev/null +++ b/tests/integration/targets/elb_target/defaults/main.yml @@ -0,0 +1,15 @@ +unique_id: "ansible-test-{{ tiny_prefix }}" + +# Defaults used by the lambda based test + +lambda_role_name: '{{ unique_id }}-elb-target' +lambda_name: '{{ unique_id }}-elb-target' +elb_target_group_name: "{{ unique_id }}-elb-tg" + +# Defaults used by the EC2 based test +ec2_ami_name: 'amzn2-ami-hvm-2.0.20190612-x86_64-gp2' +tg_name: "{{ unique_id }}-tg" +tg_tcpudp_name: "{{ unique_id }}-tgtcpudp" +lb_name: "{{ unique_id }}-lb" +healthy_state: + state: 'healthy' diff --git a/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/files/ansible_lambda_target.py b/tests/integration/targets/elb_target/files/ansible_lambda_target.py similarity index 100% rename from tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/files/ansible_lambda_target.py rename to tests/integration/targets/elb_target/files/ansible_lambda_target.py diff --git a/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/files/assume-role.json b/tests/integration/targets/elb_target/files/assume-role.json similarity index 100% rename from tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/files/assume-role.json rename to tests/integration/targets/elb_target/files/assume-role.json diff --git a/tests/integration/targets/elb_target/playbooks/full_test.yml b/tests/integration/targets/elb_target/playbooks/full_test.yml deleted file mode 100644 index ac95c66f3de..00000000000 --- a/tests/integration/targets/elb_target/playbooks/full_test.yml +++ /dev/null @@ -1,7 +0,0 @@ -- hosts: localhost - connection: local -# environment: "{{ ansible_test.environment }}" - - roles: - - elb_lambda_target - - elb_target diff --git a/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/defaults/main.yml b/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/defaults/main.yml deleted file mode 100644 index 911e2080e8b..00000000000 --- a/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/defaults/main.yml +++ /dev/null @@ -1,5 +0,0 @@ -unique_id: "ansible-test-{{ resource_prefix | hash('md5') }}" -lambda_role_name: '{{ unique_id }}-elb-target' -#lambda_role_name: '{{ resource_prefix }}-elb-target' -lambda_name: '{{ unique_id }}-elb-target' -elb_target_group_name: "{{ unique_id | truncate(8, True, '') }}-elb-tg" diff --git a/tests/integration/targets/elb_target/playbooks/roles/elb_target/defaults/main.yml b/tests/integration/targets/elb_target/playbooks/roles/elb_target/defaults/main.yml deleted file mode 100644 index 75204ee0b02..00000000000 --- a/tests/integration/targets/elb_target/playbooks/roles/elb_target/defaults/main.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -ec2_ami_name: 'amzn2-ami-hvm-2.0.20190612-x86_64-gp2' - -unique_id: "ansible-test-{{ resource_prefix | hash('md5') | truncate(8, True, '') }}" -tg_name: "{{ unique_id }}-tg" -tg_tcpudp_name: "{{ unique_id }}-tgtcpudp" -lb_name: "{{ unique_id }}-lb" - -healthy_state: - state: 'healthy' diff --git a/tests/integration/targets/elb_target/playbooks/version_fail.yml b/tests/integration/targets/elb_target/playbooks/version_fail.yml deleted file mode 100644 index 9149f593048..00000000000 --- a/tests/integration/targets/elb_target/playbooks/version_fail.yml +++ /dev/null @@ -1,41 +0,0 @@ -- hosts: localhost - connection: local - environment: "{{ ansible_test.environment }}" - - tasks: - - name: set up aws connection info - module_defaults: - group/aws: - aws_access_key: "{{ aws_access_key }}" - aws_secret_key: "{{ aws_secret_key }}" - security_token: "{{ security_token | default(omit) }}" - region: "{{ aws_region }}" - block: - - name: set up testing target group (type=ip) - elb_target_group: - state: present - #name: "{{ unique_id }}-tg" - name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-tg" - health_check_port: 80 - protocol: http - port: 80 - vpc_id: 'vpc-abcd1234' - target_type: ip - tags: - Description: "Created by {{ resource_prefix }}" - register: elb_target_group_type_ip - ignore_errors: yes - - - name: check that setting up target group with type=ip fails with friendly message - assert: - that: - - elb_target_group_type_ip is failed - - "'msg' in elb_target_group_type_ip" - - # In the off-chance that this went (partially) through when it shouldn't... - always: - - name: Remove testing target group (type=ip) - elb_target_group: - state: absent - #name: "{{ unique_id }}-tg" - name: "ansible-test-{{ resource_prefix | regex_search('([0-9]+)$') }}-tg" diff --git a/tests/integration/targets/elb_target/runme.sh b/tests/integration/targets/elb_target/runme.sh deleted file mode 100755 index fe0850e46c9..00000000000 --- a/tests/integration/targets/elb_target/runme.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -set -eux - -# Test graceful failure for older versions of botocore -source virtualenv.sh -pip install 'botocore<=1.7.1' boto3 -ansible-playbook -i ../../inventory -v playbooks/version_fail.yml "$@" - -# Run full test suite -source virtualenv.sh -pip install 'botocore' 'boto3>=1.16.57' -ansible-playbook -i ../../inventory -v playbooks/full_test.yml "$@" diff --git a/tests/integration/targets/elb_target/playbooks/roles/elb_target/tasks/main.yml b/tests/integration/targets/elb_target/tasks/ec2_target.yml similarity index 97% rename from tests/integration/targets/elb_target/playbooks/roles/elb_target/tasks/main.yml rename to tests/integration/targets/elb_target/tasks/ec2_target.yml index 30a67cef93c..108ffa4d30b 100644 --- a/tests/integration/targets/elb_target/playbooks/roles/elb_target/tasks/main.yml +++ b/tests/integration/targets/elb_target/tasks/ec2_target.yml @@ -1,20 +1,11 @@ --- - - name: set up elb_target test prerequisites - module_defaults: - group/aws: - aws_access_key: "{{ aws_access_key }}" - aws_secret_key: "{{ aws_secret_key }}" - security_token: "{{ security_token | default(omit) }}" - region: "{{ aws_region }}" - collections: - - amazon.aws - + - name: set up ec2 based test prerequisites block: # ============================================================ - name: - debug: msg="********** Setting up elb_target test dependencies **********" + debug: msg="********** Setting up elb_target EC2 test dependencies **********" # ============================================================ - name: Find AMI to use diff --git a/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/tasks/main.yml b/tests/integration/targets/elb_target/tasks/lambda_target.yml similarity index 92% rename from tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/tasks/main.yml rename to tests/integration/targets/elb_target/tasks/lambda_target.yml index fb310b848c5..8b7955ddbe3 100644 --- a/tests/integration/targets/elb_target/playbooks/roles/elb_lambda_target/tasks/main.yml +++ b/tests/integration/targets/elb_target/tasks/lambda_target.yml @@ -1,13 +1,6 @@ - name: set up lambda as elb_target - module_defaults: - group/aws: - aws_access_key: '{{ aws_access_key }}' - aws_secret_key: '{{ aws_secret_key }}' - security_token: '{{ security_token | default(omit) }}' - region: '{{ aws_region }}' - collections: - - community.general block: + - name: create zip to deploy lambda code archive: path: '{{ role_path }}/files/ansible_lambda_target.py' @@ -23,6 +16,7 @@ - name: when it is too fast, the role is not usable. pause: seconds: 10 + - name: deploy lambda.zip to ansible_lambda_target function lambda: name: '{{ lambda_name }}' @@ -36,6 +30,7 @@ retries: 3 delay: 15 until: lambda_function.changed + - name: create empty target group elb_target_group: name: '{{ elb_target_group_name }}' @@ -43,10 +38,12 @@ state: present modify_targets: false register: elb_target_group + - name: tg is created, state must be changed assert: that: - elb_target_group.changed + - name: allow elb to invoke the lambda function lambda_policy: state: present @@ -56,6 +53,7 @@ action: lambda:InvokeFunction principal: elasticloadbalancing.amazonaws.com source_arn: '{{ elb_target_group.target_group_arn }}' + - name: add lambda to elb target elb_target_group: name: '{{ elb_target_group_name }}' @@ -64,10 +62,12 @@ targets: - Id: '{{ lambda_function.configuration.function_arn }}' register: elb_target_group + - name: target is updated, state must be changed assert: that: - elb_target_group.changed + - name: re-add lambda to elb target (idempotency) elb_target_group: name: '{{ elb_target_group_name }}' @@ -76,10 +76,12 @@ targets: - Id: '{{ lambda_function.configuration.function_arn }}' register: elb_target_group + - name: target is still the same, state must not be changed (idempotency) assert: that: - not elb_target_group.changed + - name: remove lambda target from target group elb_target_group: name: '{{ elb_target_group_name }}' @@ -87,10 +89,12 @@ state: absent targets: [] register: elb_target_group + - name: target is still the same, state must not be changed (idempotency) assert: that: - elb_target_group.changed + always: - name: remove elb target group elb_target_group: @@ -98,11 +102,13 @@ target_type: lambda state: absent ignore_errors: true + - name: remove lambda function lambda: name: '{{ lambda_name }}' state: absent ignore_errors: true + - name: remove iam role for lambda iam_role: name: '{{ lambda_role_name }}' diff --git a/tests/integration/targets/elb_target/tasks/main.yml b/tests/integration/targets/elb_target/tasks/main.yml new file mode 100644 index 00000000000..e6c62f922d3 --- /dev/null +++ b/tests/integration/targets/elb_target/tasks/main.yml @@ -0,0 +1,13 @@ +--- +- name: set up elb_target test prerequisites + module_defaults: + group/aws: + aws_access_key: "{{ aws_access_key }}" + aws_secret_key: "{{ aws_secret_key }}" + security_token: "{{ security_token | default(omit) }}" + region: "{{ aws_region }}" + collections: + - amazon.aws + block: + - include_tasks: lambda_target.yml + - include_tasks: ec2_target.yml