Increase delay and tries for ec2_vpc_net backoff - fixes #36063, fixes #37323, fixes #36078 (#37354)

* Increase delay and tries for ec2_vpc_net backoff

Wait for DHCP option to be created in ec2_vpc_dhcp_option

Wait for all modifications to the VPC

* Use the vpc_available waiter because is uses Filters

* Missed one

* Optimize retries to only occur if the functionality is available

* Increase max wait time

* Add comments to explain what the waiters are doing
This commit is contained in:
Sloane Hertel 2018-03-15 18:07:54 -04:00 committed by Will Thames
parent cdd21e2170
commit 16f8a993a0
2 changed files with 91 additions and 14 deletions

View file

@ -187,7 +187,7 @@ EXAMPLES = """
import collections
import traceback
from time import sleep, time
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ec2 import HAS_BOTO, connect_to_aws, ec2_argument_spec, get_aws_connection_info
@ -359,6 +359,23 @@ def main():
new_options['ntp-servers'],
new_options['netbios-name-servers'],
new_options['netbios-node-type'])
# wait for dhcp option to be accessible
found_dhcp_opt = False
start_time = time()
while time() < start_time + 300:
try:
found_dhcp_opt = connection.get_all_dhcp_options(dhcp_options_ids=[dhcp_option.id])
except EC2ResponseError as e:
if e.error_code == 'InvalidDhcpOptionID.NotFound':
sleep(3)
else:
module.fail_json(msg="Failed to describe DHCP options", exception=traceback.format_exc)
else:
break
if not found_dhcp_opt:
module.fail_json(msg="Failed to wait for {0} to be available.".format(dhcp_option.id))
changed = True
if params['tags']:
ensure_tags(module, connection, dhcp_option.id, params['tags'], False, module.check_mode)