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
b793248d
Commit
b793248d
authored
Oct 18, 2013
by
Peter Sankauskas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Now this disassociates EIPs from instances inside a VPC correctly. Time
for a PR.
parent
0e459f65
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
library/cloud/ec2_eip
+13
-5
No files found.
library/cloud/ec2_eip
View file @
b793248d
...
@@ -154,15 +154,22 @@ def associate_ip_and_instance(ec2, address, instance_id, module):
...
@@ -154,15 +154,22 @@ def associate_ip_and_instance(ec2, address, instance_id, module):
module
.
fail_json
(
msg
=
"association failed"
)
module
.
fail_json
(
msg
=
"association failed"
)
def
disassociate_ip_and_instance
(
ec2
,
public_ip
,
instance_id
,
module
):
def
disassociate_ip_and_instance
(
ec2
,
address
,
instance_id
,
module
):
if
not
ip_is_associated_with_instance
(
ec2
,
public_ip
,
instance_id
,
module
):
if
not
ip_is_associated_with_instance
(
ec2
,
address
.
public_ip
,
instance_id
,
module
):
module
.
exit_json
(
changed
=
False
,
public_ip
=
public_ip
)
module
.
exit_json
(
changed
=
False
,
public_ip
=
address
.
public_ip
)
# If we're in check mode, nothing else to do
# If we're in check mode, nothing else to do
if
module
.
check_mode
:
if
module
.
check_mode
:
module
.
exit_json
(
changed
=
True
)
module
.
exit_json
(
changed
=
True
)
res
=
ec2
.
disassociate_address
(
public_ip
)
try
:
if
address
.
domain
==
"vpc"
:
res
=
ec2
.
disassociate_address
(
association_id
=
address
.
association_id
)
else
:
res
=
ec2
.
disassociate_address
(
public_ip
=
address
.
public_ip
)
except
boto
.
exception
.
EC2ResponseError
,
e
:
module
.
fail_json
(
msg
=
str
(
e
))
if
res
:
if
res
:
module
.
exit_json
(
changed
=
True
)
module
.
exit_json
(
changed
=
True
)
else
:
else
:
...
@@ -279,7 +286,8 @@ def main():
...
@@ -279,7 +286,8 @@ def main():
if
instance_id
is
None
:
if
instance_id
is
None
:
release_address
(
ec2
,
public_ip
,
module
)
release_address
(
ec2
,
public_ip
,
module
)
else
:
else
:
disassociate_ip_and_instance
(
ec2
,
public_ip
,
instance_id
,
module
)
address
=
find_address
(
ec2
,
public_ip
,
module
)
disassociate_ip_and_instance
(
ec2
,
address
,
instance_id
,
module
)
...
...
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