Merge pull request #5380 from dhml/devel
ec2_group: rules can't reference containing group fix #5309
This commit is contained in:
commit
821858ed08
1 changed files with 18 additions and 1 deletions
|
@ -87,7 +87,10 @@ EXAMPLES = '''
|
||||||
- proto: udp
|
- proto: udp
|
||||||
from_port: 10051
|
from_port: 10051
|
||||||
to_port: 10051
|
to_port: 10051
|
||||||
group_id: abcdef
|
group_id: sg-12345678
|
||||||
|
- proto: all
|
||||||
|
# the containing group name may be specified here
|
||||||
|
group_name: example
|
||||||
'''
|
'''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -134,6 +137,7 @@ def main():
|
||||||
groups = {}
|
groups = {}
|
||||||
for curGroup in ec2.get_all_security_groups():
|
for curGroup in ec2.get_all_security_groups():
|
||||||
groups[curGroup.id] = curGroup
|
groups[curGroup.id] = curGroup
|
||||||
|
groups[curGroup.name] = curGroup
|
||||||
|
|
||||||
if curGroup.name == name and curGroup.vpc_id == vpc_id:
|
if curGroup.name == name and curGroup.vpc_id == vpc_id:
|
||||||
group = curGroup
|
group = curGroup
|
||||||
|
@ -185,11 +189,24 @@ def main():
|
||||||
if rules:
|
if rules:
|
||||||
for rule in rules:
|
for rule in rules:
|
||||||
group_id = None
|
group_id = None
|
||||||
|
group_name = None
|
||||||
ip = None
|
ip = None
|
||||||
if 'group_id' in rule and 'cidr_ip' in rule:
|
if 'group_id' in rule and 'cidr_ip' in rule:
|
||||||
module.fail_json(msg="Specify group_id OR cidr_ip, not both")
|
module.fail_json(msg="Specify group_id OR cidr_ip, not both")
|
||||||
|
elif 'group_name' in rule and 'cidr_ip' in rule:
|
||||||
|
module.fail_json(msg="Specify group_name OR cidr_ip, not both")
|
||||||
|
elif 'group_id' in rule and 'group_name' in rule:
|
||||||
|
module.fail_json(msg="Specify group_id OR group_name, not both")
|
||||||
elif 'group_id' in rule:
|
elif 'group_id' in rule:
|
||||||
group_id = rule['group_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:
|
||||||
|
group_id = group.id
|
||||||
|
groups[group_id] = group
|
||||||
|
groups[group_name] = group
|
||||||
elif 'cidr_ip' in rule:
|
elif 'cidr_ip' in rule:
|
||||||
ip = rule['cidr_ip']
|
ip = rule['cidr_ip']
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue