From c3e720a393eb3a8ab09ae4b6561b50b772752e5f Mon Sep 17 00:00:00 2001 From: zimbatm Date: Mon, 27 Apr 2015 19:26:13 +0100 Subject: [PATCH] ec2_group: select own group if the name matches This fixes an issue where multiple VPC have the same group name and the one from the other VPC is selected. --- lib/ansible/modules/cloud/amazon/ec2_group.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/ec2_group.py b/lib/ansible/modules/cloud/amazon/ec2_group.py index 9fca4364a15..96263a2615d 100644 --- a/lib/ansible/modules/cloud/amazon/ec2_group.py +++ b/lib/ansible/modules/cloud/amazon/ec2_group.py @@ -162,12 +162,12 @@ def get_target_from_rule(module, ec2, rule, name, group, groups, vpc_id): group_id = rule['group_id'] elif 'group_name' in rule: group_name = rule['group_name'] - if group_name in groups: - group_id = groups[group_name].id - elif group_name == name: + if group_name == name: group_id = group.id groups[group_id] = group groups[group_name] = group + elif group_name in groups: + group_id = groups[group_name].id else: if not rule.get('group_desc', '').strip(): module.fail_json(msg="group %s will be automatically created by rule %s and no description was provided" % (group_name, rule))