Merge branch 'fix_ec2_eip' of https://github.com/jsmartin/ansible into jsmartin-fix_ec2_eip
This commit is contained in:
commit
3281139981
1 changed files with 17 additions and 5 deletions
|
@ -138,10 +138,22 @@ def disassociate_ip_and_instance(ec2, address, instance_id, module):
|
||||||
def find_address(ec2, public_ip, module):
|
def find_address(ec2, public_ip, module):
|
||||||
""" Find an existing Elastic IP address """
|
""" Find an existing Elastic IP address """
|
||||||
|
|
||||||
|
wait_timeout = 600
|
||||||
|
wait_timeout = time.time() + wait_timeout
|
||||||
|
|
||||||
|
while wait_timeout > time.time():
|
||||||
try:
|
try:
|
||||||
addresses = ec2.get_all_addresses([public_ip])
|
addresses = ec2.get_all_addresses([public_ip])
|
||||||
|
break
|
||||||
except boto.exception.EC2ResponseError, e:
|
except boto.exception.EC2ResponseError, e:
|
||||||
|
if "Address '%s' not found." % public_ip in e.message :
|
||||||
|
pass
|
||||||
|
else:
|
||||||
module.fail_json(msg=str(e.message))
|
module.fail_json(msg=str(e.message))
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
if wait_timeout <= time.time():
|
||||||
|
module.fail_json(msg = "wait for EIPs timeout on %s" % time.asctime())
|
||||||
|
|
||||||
return addresses[0]
|
return addresses[0]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue