Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
f7431660
Commit
f7431660
authored
Apr 05, 2013
by
Mario Franco
Committed by
Michael DeHaan
May 05, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix security group id for vpc based on @samukasmk solution
parent
29d1b08d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
15 deletions
+32
-15
library/cloud/ec2
+32
-15
No files found.
library/cloud/ec2
View file @
f7431660
...
...
@@ -277,11 +277,22 @@ def main():
module
.
fail_json
(
msg
=
str
(
e
))
# Here we try to lookup the group name from the security group id - if group_id is set.
if
group_id
and
group_name
:
module
.
fail_json
(
msg
=
str
(
"Use only one type of parameter (group_name) or (group_id)"
))
sys
.
exit
(
1
)
try
:
if
group_id
:
# Here we try to lookup the group id from the security group name - if group is set.
if
group_name
:
grp_details
=
ec2
.
get_all_security_groups
()
for
grp
in
grp_details
:
if
str
(
group_name
)
in
str
(
grp
):
group_id
=
str
(
grp
.
id
)
# Now we try to lookup the group id testing if group exists.
elif
group_id
:
grp_details
=
ec2
.
get_all_security_groups
(
group_ids
=
group_id
)
grp_item
=
grp_details
[
0
]
group_name
=
grp_item
.
name
group_name
=
grp_item
.
name
except
boto
.
exception
.
NoAuthHandlerFound
,
e
:
module
.
fail_json
(
msg
=
str
(
e
))
...
...
@@ -303,19 +314,25 @@ def main():
if
count_remaining
>
0
:
try
:
res
=
ec2
.
run_instances
(
image
,
key_name
=
key_name
,
client_token
=
id
,
min_count
=
count_remaining
,
max_count
=
count_remaining
,
monitoring_enabled
=
monitoring
,
security_groups
=
[
group_name
],
placement
=
zone
,
instance_type
=
instance_type
,
kernel_id
=
kernel
,
ramdisk_id
=
ramdisk
,
subnet_id
=
vpc_subnet_id
,
private_ip_address
=
private_ip
,
user_data
=
user_data
)
params
=
{
'image_id'
:
image
,
'key_name'
:
key_name
,
'client_token'
:
id
,
'min_count'
:
count_remaining
,
'max_count'
:
count_remaining
,
'monitoring_enabled'
:
monitoring
,
'instance_type'
:
instance_type
,
'kernel_id'
:
kernel
,
'ramdisk_id'
:
ramdisk
,
'subnet_id'
:
vpc_subnet_id
,
'private_ip_address'
:
private_ip
,
'user_data'
:
user_data
}
if
vpc_subnet_id
:
params
[
'security_group_ids'
]
=
[
group_id
]
else
:
params
[
'security_groups'
]
=
[
group_name
]
res
=
ec2
.
run_instances
(
**
params
)
except
boto
.
exception
.
BotoServerError
,
e
:
module
.
fail_json
(
msg
=
"
%
s:
%
s"
%
(
e
.
error_code
,
e
.
error_message
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment