mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 05:10:22 -07:00
[cloud] ec2_ami_copy: undeprecate wait_timeout to allow modifiable timeouts again to allow a longer timeout than 600 seconds (#37680)
Fixes #37111
This commit is contained in:
parent
868811adbc
commit
3a5a0fed06
1 changed files with 12 additions and 4 deletions
|
@ -58,8 +58,10 @@ options:
|
||||||
default: 'no'
|
default: 'no'
|
||||||
wait_timeout:
|
wait_timeout:
|
||||||
description:
|
description:
|
||||||
- How long before wait gives up, in seconds. (As of 2.3 this option is deprecated. See boto3 Waiters)
|
- How long before wait gives up, in seconds. Prior to 2.3 the default was 1200.
|
||||||
default: 1200
|
- From 2.3-2.5 this option was deprecated in favor of boto3 waiter defaults.
|
||||||
|
This was reenabled in 2.6 to allow timeouts greater than 10 minutes.
|
||||||
|
default: 600
|
||||||
tags:
|
tags:
|
||||||
description:
|
description:
|
||||||
- A hash/dictionary of tags to add to the new copied AMI; '{"key":"value"}' and '{"key":"value","key":"value"}'
|
- A hash/dictionary of tags to add to the new copied AMI; '{"key":"value"}' and '{"key":"value","key":"value"}'
|
||||||
|
@ -84,6 +86,7 @@ EXAMPLES = '''
|
||||||
region: eu-west-1
|
region: eu-west-1
|
||||||
source_image_id: ami-xxxxxxx
|
source_image_id: ami-xxxxxxx
|
||||||
wait: yes
|
wait: yes
|
||||||
|
wait_timeout: 1200 # Default timeout is 600
|
||||||
register: image_id
|
register: image_id
|
||||||
|
|
||||||
# Named AMI copy
|
# Named AMI copy
|
||||||
|
@ -159,7 +162,12 @@ def copy_image(module, ec2):
|
||||||
try:
|
try:
|
||||||
image_id = ec2.copy_image(**params)['ImageId']
|
image_id = ec2.copy_image(**params)['ImageId']
|
||||||
if module.params.get('wait'):
|
if module.params.get('wait'):
|
||||||
ec2.get_waiter('image_available').wait(ImageIds=[image_id])
|
delay = 15
|
||||||
|
max_attempts = module.params.get('wait_timeout') // delay
|
||||||
|
ec2.get_waiter('image_available').wait(
|
||||||
|
ImageIds=[image_id],
|
||||||
|
WaiterConfig={'Delay': delay, 'MaxAttempts': max_attempts}
|
||||||
|
)
|
||||||
if module.params.get('tags'):
|
if module.params.get('tags'):
|
||||||
ec2.create_tags(
|
ec2.create_tags(
|
||||||
Resources=[image_id],
|
Resources=[image_id],
|
||||||
|
@ -187,7 +195,7 @@ def main():
|
||||||
encrypted=dict(type='bool', default=False, required=False),
|
encrypted=dict(type='bool', default=False, required=False),
|
||||||
kms_key_id=dict(type='str', required=False),
|
kms_key_id=dict(type='str', required=False),
|
||||||
wait=dict(type='bool', default=False),
|
wait=dict(type='bool', default=False),
|
||||||
wait_timeout=dict(default=1200),
|
wait_timeout=dict(type='int', default=600),
|
||||||
tags=dict(type='dict')))
|
tags=dict(type='dict')))
|
||||||
|
|
||||||
module = AnsibleModule(argument_spec=argument_spec)
|
module = AnsibleModule(argument_spec=argument_spec)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue