mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 03:00:23 -07:00
Added wait_timeout option
This commit is contained in:
parent
c900254ed0
commit
436b59252c
1 changed files with 6 additions and 0 deletions
|
@ -125,6 +125,7 @@ def main():
|
||||||
ec2_secret_key = dict(aliases=['aws_secret_key', 'secret_key'], no_log=True),
|
ec2_secret_key = dict(aliases=['aws_secret_key', 'secret_key'], no_log=True),
|
||||||
ec2_access_key = dict(aliases=['aws_access_key', 'access_key']),
|
ec2_access_key = dict(aliases=['aws_access_key', 'access_key']),
|
||||||
wait = dict(choices=BOOLEANS, default='true'),
|
wait = dict(choices=BOOLEANS, default='true'),
|
||||||
|
wait_timeout = dict(type='number', default=0),
|
||||||
snapshot_tags = dict(type='dict', default=dict()),
|
snapshot_tags = dict(type='dict', default=dict()),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -134,6 +135,7 @@ def main():
|
||||||
instance_id = module.params.get('instance_id')
|
instance_id = module.params.get('instance_id')
|
||||||
device_name = module.params.get('device_name')
|
device_name = module.params.get('device_name')
|
||||||
wait = module.params.get('wait')
|
wait = module.params.get('wait')
|
||||||
|
wait_timeout = module.params.get('wait_timeout')
|
||||||
snapshot_tags = module.params.get('snapshot_tags')
|
snapshot_tags = module.params.get('snapshot_tags')
|
||||||
|
|
||||||
if not volume_id and not instance_id or volume_id and instance_id:
|
if not volume_id and not instance_id or volume_id and instance_id:
|
||||||
|
@ -154,11 +156,15 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
snapshot = ec2.create_snapshot(volume_id, description=description)
|
snapshot = ec2.create_snapshot(volume_id, description=description)
|
||||||
|
time_waited = 0
|
||||||
if wait:
|
if wait:
|
||||||
snapshot.update()
|
snapshot.update()
|
||||||
while snapshot.status != 'completed':
|
while snapshot.status != 'completed':
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
snapshot.update()
|
snapshot.update()
|
||||||
|
time_waited += 3
|
||||||
|
if wait_timeout and time_waited > wait_timeout:
|
||||||
|
module.fail_json('Timed out while creating snapshot.')
|
||||||
for k, v in snapshot_tags.items():
|
for k, v in snapshot_tags.items():
|
||||||
snapshot.add_tag(k, v)
|
snapshot.add_tag(k, v)
|
||||||
except boto.exception.BotoServerError, e:
|
except boto.exception.BotoServerError, e:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue