Merge pull request #7827 from willthames/delay_tagging_in_ec2
ec2 module: Delay instance tagging to later in the instance creation process
This commit is contained in:
commit
56583f6006
1 changed files with 7 additions and 6 deletions
13
cloud/ec2
13
cloud/ec2
|
@ -913,12 +913,6 @@ def create_instances(module, ec2, override_count=None):
|
||||||
except boto.exception.BotoServerError, e:
|
except boto.exception.BotoServerError, e:
|
||||||
module.fail_json(msg = "Instance creation failed => %s: %s" % (e.error_code, e.error_message))
|
module.fail_json(msg = "Instance creation failed => %s: %s" % (e.error_code, e.error_message))
|
||||||
|
|
||||||
if instance_tags:
|
|
||||||
try:
|
|
||||||
ec2.create_tags(instids, instance_tags)
|
|
||||||
except boto.exception.EC2ResponseError, e:
|
|
||||||
module.fail_json(msg = "Instance tagging failed => %s: %s" % (e.error_code, e.error_message))
|
|
||||||
|
|
||||||
# wait here until the instances are up
|
# wait here until the instances are up
|
||||||
num_running = 0
|
num_running = 0
|
||||||
wait_timeout = time.time() + wait_timeout
|
wait_timeout = time.time() + wait_timeout
|
||||||
|
@ -950,6 +944,13 @@ def create_instances(module, ec2, override_count=None):
|
||||||
for inst in res.instances:
|
for inst in res.instances:
|
||||||
inst.modify_attribute('sourceDestCheck', False)
|
inst.modify_attribute('sourceDestCheck', False)
|
||||||
|
|
||||||
|
# Leave this as late as possible to try and avoid InvalidInstanceID.NotFound
|
||||||
|
if instance_tags:
|
||||||
|
try:
|
||||||
|
ec2.create_tags(instids, instance_tags)
|
||||||
|
except boto.exception.EC2ResponseError, e:
|
||||||
|
module.fail_json(msg = "Instance tagging failed => %s: %s" % (e.error_code, e.error_message))
|
||||||
|
|
||||||
instance_dict_array = []
|
instance_dict_array = []
|
||||||
created_instance_ids = []
|
created_instance_ids = []
|
||||||
for inst in running_instances:
|
for inst in running_instances:
|
||||||
|
|
Loading…
Reference in a new issue