Commit 1529a974 by Ralph Tice

fixed vpc provisioning / clarified group_id usage

parent 86f05f11
...@@ -43,7 +43,7 @@ options: ...@@ -43,7 +43,7 @@ options:
group_id: group_id:
version_added: "1.1" version_added: "1.1"
description: description:
- security group id to use with the instance - security group id (or list of ids) to use with the instance
required: false required: false
default: null default: null
aliases: [] aliases: []
...@@ -232,7 +232,7 @@ local_action: ...@@ -232,7 +232,7 @@ local_action:
instance_type: m1.small instance_type: m1.small
image: ami-6e649707 image: ami-6e649707
wait: yes wait: yes
vpc_subnet_id: subnet-29e63245' vpc_subnet_id: subnet-29e63245
# Launch instances, runs some tasks # Launch instances, runs some tasks
...@@ -354,7 +354,7 @@ def create_instances(module, ec2): ...@@ -354,7 +354,7 @@ def create_instances(module, ec2):
instance_profile_name = module.params.get('instance_profile_name') instance_profile_name = module.params.get('instance_profile_name')
# Here we try to lookup the group name from the security group id - if group_id is set. # group_id and group_name are exclusive of each other
if group_id and group_name: if group_id and group_name:
module.fail_json(msg = str("Use only one type of parameter (group_name) or (group_id)")) module.fail_json(msg = str("Use only one type of parameter (group_name) or (group_id)"))
sys.exit(1) sys.exit(1)
...@@ -372,6 +372,9 @@ def create_instances(module, ec2): ...@@ -372,6 +372,9 @@ def create_instances(module, ec2):
group_name = [group_name] group_name = [group_name]
# Now we try to lookup the group id testing if group exists. # Now we try to lookup the group id testing if group exists.
elif group_id: elif group_id:
#wrap the group_id in a list if it's not one already
if type(group_id) == str:
group_id = [group_id]
grp_details = ec2.get_all_security_groups(group_ids=group_id) grp_details = ec2.get_all_security_groups(group_ids=group_id)
grp_item = grp_details[0] grp_item = grp_details[0]
group_name = [grp_item.name] group_name = [grp_item.name]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment