From f4faf9842f5ec0f33d1313e12b1570141f71b389 Mon Sep 17 00:00:00 2001 From: James Kassemi Date: Sat, 22 Oct 2016 10:46:39 -0600 Subject: [PATCH] Fix issue with multiple pages of results in ec2_lc_find (#3090) --- .../extras/cloud/amazon/ec2_lc_find.py | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_lc_find.py b/lib/ansible/modules/extras/cloud/amazon/ec2_lc_find.py index 32e0d0eb3a8..f18bdfb42be 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_lc_find.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_lc_find.py @@ -162,31 +162,32 @@ def find_launch_configs(client, module): } ) + results = [] + for response in response_iterator: response['LaunchConfigurations'] = filter(lambda lc: re.compile(name_regex).match(lc['LaunchConfigurationName']), response['LaunchConfigurations']) - results = [] - for lc in response['LaunchConfigurations']: - data = { - 'name': lc['LaunchConfigurationName'], - 'arn': lc['LaunchConfigurationARN'], - 'created_time': lc['CreatedTime'], - 'user_data': lc['UserData'], - 'instance_type': lc['InstanceType'], - 'image_id': lc['ImageId'], - 'ebs_optimized': lc['EbsOptimized'], - 'instance_monitoring': lc['InstanceMonitoring'], - 'classic_link_vpc_security_groups': lc['ClassicLinkVPCSecurityGroups'], - 'block_device_mappings': lc['BlockDeviceMappings'], - 'keyname': lc['KeyName'], - 'security_groups': lc['SecurityGroups'], - 'kernel_id': lc['KernelId'], - 'ram_disk_id': lc['RamdiskId'], - 'associate_public_address': lc['AssociatePublicIpAddress'], - } + for lc in response['LaunchConfigurations']: + data = { + 'name': lc['LaunchConfigurationName'], + 'arn': lc['LaunchConfigurationARN'], + 'created_time': lc['CreatedTime'], + 'user_data': lc['UserData'], + 'instance_type': lc['InstanceType'], + 'image_id': lc['ImageId'], + 'ebs_optimized': lc['EbsOptimized'], + 'instance_monitoring': lc['InstanceMonitoring'], + 'classic_link_vpc_security_groups': lc['ClassicLinkVPCSecurityGroups'], + 'block_device_mappings': lc['BlockDeviceMappings'], + 'keyname': lc['KeyName'], + 'security_groups': lc['SecurityGroups'], + 'kernel_id': lc['KernelId'], + 'ram_disk_id': lc['RamdiskId'], + 'associate_public_address': lc['AssociatePublicIpAddress'], + } - results.append(data) + results.append(data) results.sort(key=lambda e: e['name'], reverse=(sort_order == 'descending'))