Merge pull request #1212 from zimbatm/ec2_group-name_priority
ec2_group: select own group if the name matches
This commit is contained in:
commit
dee65f83af
1 changed files with 9 additions and 4 deletions
|
@ -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))
|
||||
|
@ -223,7 +223,12 @@ def main():
|
|||
groups = {}
|
||||
for curGroup in ec2.get_all_security_groups():
|
||||
groups[curGroup.id] = curGroup
|
||||
groups[curGroup.name] = curGroup
|
||||
if curGroup.name in groups:
|
||||
# Prioritise groups from the current VPC
|
||||
if vpc_id is None or curGroup.vpc_id == vpc_id:
|
||||
groups[curGroup.name] = curGroup
|
||||
else:
|
||||
groups[curGroup.name] = curGroup
|
||||
|
||||
if curGroup.name == name and (vpc_id is None or curGroup.vpc_id == vpc_id):
|
||||
group = curGroup
|
||||
|
|
Loading…
Reference in a new issue