From 727e533bfc5413870e1db131aff6a0259ce803e7 Mon Sep 17 00:00:00 2001 From: mattwwarren Date: Fri, 11 Nov 2016 16:02:07 -0500 Subject: [PATCH] ec2_elb_facts: fix errors with no names input (#3381) * None being passed around results in a Bad Time (tm) * need to return the full set of elbs for an empty list * logic is hard --- .../modules/extras/cloud/amazon/ec2_elb_facts.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/amazon/ec2_elb_facts.py b/lib/ansible/modules/extras/cloud/amazon/ec2_elb_facts.py index a4ccd81c65..2b38e1a9bc 100644 --- a/lib/ansible/modules/extras/cloud/amazon/ec2_elb_facts.py +++ b/lib/ansible/modules/extras/cloud/amazon/ec2_elb_facts.py @@ -203,16 +203,19 @@ class ElbInformation(object): self.module.fail_json(msg = "%s: %s" % (err.error_code, err.error_message)) if all_elbs: - for existing_lb in all_elbs: - if existing_lb.name in self.names: - elb_array.append(self._get_elb_info(existing_lb)) - - return elb_array + if self.names: + for existing_lb in all_elbs: + if existing_lb.name in self.names: + elb_array.append(existing_lb) + else: + elb_array = all_elbs + + return list(map(self._get_elb_info, elb_array)) def main(): argument_spec = ec2_argument_spec() argument_spec.update(dict( - names={'default': None, 'type': 'list'} + names={'default': [], 'type': 'list'} ) ) module = AnsibleModule(argument_spec=argument_spec)